# Author: Leah Christiani
# Article: When are explicit racial appeals accepted? Examining the role of racial status threat 
# Journal: Political Behavior 
# Year: 2021

rm(list=ls(all=TRUE))

load("~/Christiani2021_PB_Data.RData")

library(texreg)
library(xtable)
library(sjPlot)
library(ggplot2)
library(ggpubr)
library(plyr)

####
###### DATASETS:
####

data_nocontrol <- subset(data, data$condition!="Control")
data_noallay <- subset(data, data$condition!="SA_Treatment2")
data_nothreat <- subset(data, data$condition!="ST_Treatment1")

######
######## AVERAGE TREATMENT EFFECTS
######

fairpt1 = lm(w2.flyer_fairpt ~ as.factor(condition_name), data=data)
vote1 = lm(w2.flyer_vote ~ as.factor(condition_name), data=data)
offend1 = lm(w2.flyer_offend ~ as.factor(condition_name), data=data)
insens1 = lm(w2.flyer_insens ~ as.factor(condition_name), data=data)
agree1 = lm(w2.flyer_agree ~ as.factor(condition_name), data=data)
texreg(list(fairpt1, vote1, offend1, insens1, agree1), digits=2, stars=c(0.05))

models <- c("1. Fair Point", "2. Vote", "3. Offend", "4. Insensitive", "5. Agree")

coefs1 = rbind(fairpt1$coefficients[3], 
               vote1$coefficients[3],
               offend1$coefficients[3],
               insens1$coefficients[3],
               agree1$coefficients[3])
lowercis1 = rbind(confint(fairpt1, 'as.factor(condition_name)Status Threat', level=0.95)[1],
                  confint(vote1, 'as.factor(condition_name)Status Threat', level=0.95)[1],
                  confint(offend1, 'as.factor(condition_name)Status Threat', level=0.95)[1],
                  confint(insens1, 'as.factor(condition_name)Status Threat', level=0.95)[1],
                  confint(agree1, 'as.factor(condition_name)Status Threat', level=0.95)[1])
uppercis1 = rbind(confint(fairpt1, 'as.factor(condition_name)Status Threat', level=0.95)[2],
                  confint(vote1, 'as.factor(condition_name)Status Threat', level=0.95)[2],
                  confint(offend1, 'as.factor(condition_name)Status Threat', level=0.95)[2],
                  confint(insens1, 'as.factor(condition_name)Status Threat', level=0.95)[2],
                  confint(agree1, 'as.factor(condition_name)Status Threat', level=0.95)[2])

df1 <- as.data.frame(cbind(coefs1, lowercis1, uppercis1))
df1 <- cbind(df1, models)
View(df1)
names(df1) = c("coef", "lowerCI", "upperCI")

# Figure 1 
ates1 <- ggplot(df1, aes(models, coef)) + geom_point() + geom_pointrange(aes(ymin=lowerCI, ymax=upperCI)) + 
  geom_hline(yintercept=0, linetype="dashed") + theme_bw() + labs(x="Model", y="ATE") + ggtitle("") + 
  theme(text = element_text(size=16), axis.text.x = element_text(size=14, angle=45, hjust = 1), 
        axis.text.y = element_text(size=18),plot.title = element_text(hjust = 0.5)) + ylim(-1,0.8)
pdf("ATEs.pdf", width=7, height=4)
ates1
dev.off()


######
######## DENSITY PLOT
######

mu <- ddply(data, "condition_name", summarise, grp.mean=mean(w2.article_feel_1, na.rm=T))
head(mu)
mu = subset(mu, mu$condition_name!="Status Allay")

# Figure 3a: Status threat vs control: 
surv1density <- ggplot(data=data_noallay, aes(x=w2.article_feel_combo_anxiety3, 
                                              group=condition_name,
                                              linetype=condition_name)) +
  geom_density() + theme_classic()+
  scale_linetype_manual(values=c("dotted", "solid"))+
  labs(title="",x="Anxiety", y = "Density") + theme(legend.title=element_blank(), 
                                                    plot.title = element_text(hjust = 0.5),
                                                    text = element_text(size=24), axis.text.x = element_text(size=22), 
                                                    axis.text.y = element_text(size=26)) 

pdf("surv1density.pdf")
surv1density
dev.off()

# Figure 3b and 3c: 
data_statusthreatonly = subset(data_noallay, data_noallay$condition_name=="Status Threat")
data_statusthreatonly = subset(data_statusthreatonly, data_statusthreatonly$pid_naive!="NA")
mu_rr <- ddply(data_statusthreatonly, "rr_bin", summarise, grp.mean=mean(w2.article_feel_1, na.rm=T))
mu_pid <- ddply(data_statusthreatonly, "pid_naive", summarise, grp.mean=mean(w2.article_feel_1, na.rm=T))

# racial resentment
surv1density_binnedrr <- ggplot(data=data_statusthreatonly, aes(x=w2.article_feel_1, 
                                                                group=rr_bin,
                                                                linetype=rr_bin)) +
  geom_density() + theme_classic()+
  scale_linetype_manual(values=c("solid","dotted", "dashed"))+
  labs(title="",x="Anxiety", y = "Density") + theme(legend.title=element_blank(), 
                                                    plot.title = element_text(hjust = 0.5),
                                                    text = element_text(size=24), axis.text.x = element_text(size=22), 
                                                    axis.text.y = element_text(size=26))

pdf("surv1density_binnedrr.pdf")
surv1density_binnedrr
dev.off()

# party identification 
surv1density_binnedpid = ggplot(data=data_statusthreatonly, aes(x=w2.article_feel_1, 
                                                                group=pid_naive,
                                                                linetype=pid_naive)) +
  geom_density()+ theme_classic() + 
  scale_linetype_manual(values=c("solid","dotted", "dashed")) + 
  labs(title="",x="Anxiety", y = "Density") + theme(legend.title=element_blank(), 
                                                    plot.title = element_text(hjust = 0.5),
                                                    text = element_text(size=24), axis.text.x = element_text(size=22), 
                                                    axis.text.y = element_text(size=26))

pdf("surv1density_binnedpid.pdf")
surv1density_binnedpid
dev.off()

######
######## MEDIATION MODELS
######

# Table 1: Status threat condition compared to the true control. no status allay condition

data_noallay$condition3 = ifelse(data_noallay$condition_name=="Control", 0,
                                 ifelse(data_noallay$condition_name=="Status Threat", 1, NA))

### Mediator: Anxiety
data_noallay2 <- data_noallay
data_noallay2 <- data_noallay2[,c("w2.article_feel_1", "condition3", "w2.flyer_agree", "w2.flyer_insens", "w2.flyer_fairpt", "w2.flyer_offend", "w2.flyer_conflict", "w2.flyer_vote", "racialresentment", "gender", "partyidentification", "ideology", "education", "income", "age")]
data_noallay2 <- data_noallay2[complete.cases(data_noallay2), ]

# ensure treatment indicator is a factor variable
data_noallay2$condition3 <- as.factor(data_noallay2$condition3)

# specify the model that predicts the mediator
model_med = lm(w2.article_feel_1 ~ condition3 + gender + racialresentment + ideology + education + income + age + partyidentification, data = data_noallay2)

set.seed(235)
# fair point
model_out_fairpt = lm(w2.flyer_fairpt ~ condition3 * w2.article_feel_1 + gender + racialresentment + ideology + education + income + age + partyidentification, data=data_noallay2)
model_combo_fairpt = mediation::mediate(model_med, model_out_fairpt, treat="condition3", mediator="w2.article_feel_1", sims=1000)
summary(model_combo_fairpt)

# vote
model_out_vote = lm(w2.flyer_vote ~ condition3 * w2.article_feel_1 + gender + racialresentment + ideology + education + income + age + partyidentification, data=data_noallay2)
model_combo_vote = mediation::mediate(model_med, model_out_vote, treat="condition3", mediator="w2.article_feel_1", sims=1000)
summary(model_combo_vote)

# offend
model_out_offend = lm(w2.flyer_offend ~ condition3 * w2.article_feel_1 + gender + racialresentment + partyidentification + ideology + education + income + age, data=data_noallay2)
model_combo_offend = mediation::mediate(model_med, model_out_offend, treat="condition3", mediator="w2.article_feel_1", sims=1000)
summary(model_combo_offend)

# insensitive
model_out_insens = lm(w2.flyer_insens ~ condition3 * w2.article_feel_1 + gender + racialresentment + partyidentification + ideology + education + income + age, data=data_noallay2)
model_combo_insens = mediation::mediate(model_med, model_out_insens, treat="condition3", mediator="w2.article_feel_1", sims=1000)
summary(model_combo_insens)

# agree
model_out_agree = lm(w2.flyer_agree ~ condition3 * w2.article_feel_1 + gender + racialresentment + partyidentification + ideology + education + income + age, data=data_noallay2)
model_combo_agree = mediation::mediate(model_med, model_out_agree, treat="condition3", mediator="w2.article_feel_1", sims=1000)
summary(model_combo_agree)

### Mediator: Pride

data_noallay2 <- data_noallay
data_noallay2 <- data_noallay2[,c("w2.article_feel_2", "condition3", "w2.flyer_agree", "w2.flyer_insens", "w2.flyer_fairpt", "w2.flyer_offend", "w2.flyer_conflict", "w2.flyer_vote", "racialresentment", "gender", "partyidentification", "ideology", "education", "income", "age")]
data_noallay2 <- data_noallay2[complete.cases(data_noallay2), ]

# ensure treatment indicator is a factor variable
data_noallay2$condition3 <- as.factor(data_noallay2$condition3)

# specify the model that predicts the mediator
model_med = lm(w2.article_feel_2 ~ condition3 + gender + racialresentment + ideology + education + income + age + partyidentification, data = data_noallay2)

set.seed(235)
# fair point
model_out_fairpt = lm(w2.flyer_fairpt ~ condition3 * w2.article_feel_2 + gender + racialresentment + ideology + education + income + age + partyidentification, data=data_noallay2)
model_combo_fairpt = mediation::mediate(model_med, model_out_fairpt, treat="condition3", mediator="w2.article_feel_2", sims=1000)
summary(model_combo_fairpt)

# vote
model_out_vote = lm(w2.flyer_vote ~ condition3 * w2.article_feel_2 + gender + racialresentment + ideology + education + income + age + partyidentification, data=data_noallay2)
model_combo_vote = mediation::mediate(model_med, model_out_vote, treat="condition3", mediator="w2.article_feel_2", sims=1000)
summary(model_combo_vote)

# offend
model_out_offend = lm(w2.flyer_offend ~ condition3 * w2.article_feel_2 + gender + racialresentment + partyidentification + ideology + education + income + age, data=data_noallay2)
model_combo_offend = mediation::mediate(model_med, model_out_offend, treat="condition3", mediator="w2.article_feel_2", sims=1000)
summary(model_combo_offend)

# insensitive
model_out_insens = lm(w2.flyer_insens ~ condition3 * w2.article_feel_2 + gender + racialresentment + partyidentification + ideology + education + income + age, data=data_noallay2)
model_combo_insens = mediation::mediate(model_med, model_out_insens, treat="condition3", mediator="w2.article_feel_2", sims=1000)
summary(model_combo_insens)

# agree
model_out_agree = lm(w2.flyer_agree ~ condition3 * w2.article_feel_2 + gender + racialresentment + partyidentification + ideology + education + income + age, data=data_noallay2)
model_combo_agree = mediation::mediate(model_med, model_out_agree, treat="condition3", mediator="w2.article_feel_2", sims=1000)
summary(model_combo_agree)

### Mediator: Anger

data_noallay2 <- data_noallay
data_noallay2 <- data_noallay2[,c("w2.article_feel_3", "condition3", "w2.flyer_agree", "w2.flyer_insens", "w2.flyer_fairpt", "w2.flyer_offend", "w2.flyer_conflict", "w2.flyer_vote", "racialresentment", "gender", "partyidentification", "ideology", "education", "income", "age")]
data_noallay2 <- data_noallay2[complete.cases(data_noallay2), ]

# ensure treatment indicator is a factor variable
data_noallay2$condition3 <- as.factor(data_noallay2$condition3)

# specify the model that predicts the mediator
model_med = lm(w2.article_feel_3 ~ condition3 + gender + racialresentment + ideology + education + income + age + partyidentification, data = data_noallay2)

set.seed(235)
# fair point
model_out_fairpt = lm(w2.flyer_fairpt ~ condition3 * w2.article_feel_3 + gender + racialresentment + ideology + education + income + age + partyidentification, data=data_noallay2)
model_combo_fairpt = mediation::mediate(model_med, model_out_fairpt, treat="condition3", mediator="w2.article_feel_3", sims=1000)
summary(model_combo_fairpt)

# vote
model_out_vote = lm(w2.flyer_vote ~ condition3 * w2.article_feel_3 + gender + racialresentment + ideology + education + income + age + partyidentification, data=data_noallay2)
model_combo_vote = mediation::mediate(model_med, model_out_vote, treat="condition3", mediator="w2.article_feel_3", sims=1000)
summary(model_combo_vote)

# offend
model_out_offend = lm(w2.flyer_offend ~ condition3 * w2.article_feel_3 + gender + racialresentment + partyidentification + ideology + education + income + age, data=data_noallay2)
model_combo_offend = mediation::mediate(model_med, model_out_offend, treat="condition3", mediator="w2.article_feel_3", sims=1000)
summary(model_combo_offend)

# insensitive
model_out_insens = lm(w2.flyer_insens ~ condition3 * w2.article_feel_3 + gender + racialresentment + partyidentification + ideology + education + income + age, data=data_noallay2)
model_combo_insens = mediation::mediate(model_med, model_out_insens, treat="condition3", mediator="w2.article_feel_3", sims=1000)
summary(model_combo_insens)

# agree
model_out_agree = lm(w2.flyer_agree ~ condition3 * w2.article_feel_3 + gender + racialresentment + partyidentification + ideology + education + income + age, data=data_noallay2)
model_combo_agree = mediation::mediate(model_med, model_out_agree, treat="condition3", mediator="w2.article_feel_3", sims=1000)
summary(model_combo_agree)

### Mediator: Hope

data_noallay2 <- data_noallay
data_noallay2 <- data_noallay2[,c("w2.article_feel_4", "condition3", "w2.flyer_agree", "w2.flyer_insens", "w2.flyer_fairpt", "w2.flyer_offend", "w2.flyer_conflict", "w2.flyer_vote", "racialresentment", "gender", "partyidentification", "ideology", "education", "income", "age")]
data_noallay2 <- data_noallay2[complete.cases(data_noallay2), ]

# ensure treatment indicator is a factor variable
data_noallay2$condition3 <- as.factor(data_noallay2$condition3)

# specify the model that predicts the mediator
model_med = lm(w2.article_feel_4 ~ condition3 + gender + racialresentment + ideology + education + income + age + partyidentification, data = data_noallay2)

set.seed(235)
# fair point
model_out_fairpt = lm(w2.flyer_fairpt ~ condition3 * w2.article_feel_4 + gender + racialresentment + ideology + education + income + age + partyidentification, data=data_noallay2)
model_combo_fairpt = mediation::mediate(model_med, model_out_fairpt, treat="condition3", mediator="w2.article_feel_4", sims=1000)
summary(model_combo_fairpt)

# vote
model_out_vote = lm(w2.flyer_vote ~ condition3 * w2.article_feel_4 + gender + racialresentment + ideology + education + income + age + partyidentification, data=data_noallay2)
model_combo_vote = mediation::mediate(model_med, model_out_vote, treat="condition3", mediator="w2.article_feel_4", sims=1000)
summary(model_combo_vote)

# offend
model_out_offend = lm(w2.flyer_offend ~ condition3 * w2.article_feel_4 + gender + racialresentment + partyidentification + ideology + education + income + age, data=data_noallay2)
model_combo_offend = mediation::mediate(model_med, model_out_offend, treat="condition3", mediator="w2.article_feel_4", sims=1000)
summary(model_combo_offend)

# insensitive
model_out_insens = lm(w2.flyer_insens ~ condition3 * w2.article_feel_4 + gender + racialresentment + partyidentification + ideology + education + income + age, data=data_noallay2)
model_combo_insens = mediation::mediate(model_med, model_out_insens, treat="condition3", mediator="w2.article_feel_4", sims=1000)
summary(model_combo_insens)

# agree
model_out_agree = lm(w2.flyer_agree ~ condition3 * w2.article_feel_4 + gender + racialresentment + partyidentification + ideology + education + income + age, data=data_noallay2)
model_combo_agree = mediation::mediate(model_med, model_out_agree, treat="condition3", mediator="w2.article_feel_4", sims=1000)
summary(model_combo_agree)

### Mediator: Worry 

data_noallay2 <- data_noallay
data_noallay2 <- data_noallay2[,c("w2.article_feel_5", "condition3", "w2.flyer_agree", "w2.flyer_insens", "w2.flyer_fairpt", "w2.flyer_offend", "w2.flyer_conflict", "w2.flyer_vote", "racialresentment", "gender", "partyidentification", "ideology", "education", "income", "age")]
data_noallay2 <- data_noallay2[complete.cases(data_noallay2), ]

# ensure treatment indicator is a factor variable
data_noallay2$condition3 <- as.factor(data_noallay2$condition3)

# specify the model that predicts the mediator
model_med = lm(w2.article_feel_5 ~ condition3 + gender + racialresentment + ideology + education + income + age + partyidentification, data = data_noallay2)

set.seed(235)
# fair point
model_out_fairpt = lm(w2.flyer_fairpt ~ condition3 * w2.article_feel_5 + gender + racialresentment + ideology + education + income + age + partyidentification, data=data_noallay2)
model_combo_fairpt = mediation::mediate(model_med, model_out_fairpt, treat="condition3", mediator="w2.article_feel_5", sims=1000)
summary(model_combo_fairpt)

# vote
model_out_vote = lm(w2.flyer_vote ~ condition3 * w2.article_feel_5 + gender + racialresentment + ideology + education + income + age + partyidentification, data=data_noallay2)
model_combo_vote = mediation::mediate(model_med, model_out_vote, treat="condition3", mediator="w2.article_feel_5", sims=1000)
summary(model_combo_vote)

# offend
model_out_offend = lm(w2.flyer_offend ~ condition3 * w2.article_feel_5 + gender + racialresentment + partyidentification + ideology + education + income + age, data=data_noallay2)
model_combo_offend = mediation::mediate(model_med, model_out_offend, treat="condition3", mediator="w2.article_feel_5", sims=1000)
summary(model_combo_offend)

# insensitive
model_out_insens = lm(w2.flyer_insens ~ condition3 * w2.article_feel_5 + gender + racialresentment + partyidentification + ideology + education + income + age, data=data_noallay2)
model_combo_insens = mediation::mediate(model_med, model_out_insens, treat="condition3", mediator="w2.article_feel_5", sims=1000)
summary(model_combo_insens)

# agree
model_out_agree = lm(w2.flyer_agree ~ condition3 * w2.article_feel_5 + gender + racialresentment + partyidentification + ideology + education + income + age, data=data_noallay2)
model_combo_agree = mediation::mediate(model_med, model_out_agree, treat="condition3", mediator="w2.article_feel_5", sims=1000)
summary(model_combo_agree)

### Mediator: Excited

data_noallay2 <- data_noallay
data_noallay2 <- data_noallay2[,c("w2.article_feel_6", "condition3", "w2.flyer_agree", "w2.flyer_insens", "w2.flyer_fairpt", "w2.flyer_offend", "w2.flyer_conflict", "w2.flyer_vote", "racialresentment", "gender", "partyidentification", "ideology", "education", "income", "age")]
data_noallay2 <- data_noallay2[complete.cases(data_noallay2), ]

# ensure treatment indicator is a factor variable
data_noallay2$condition3 <- as.factor(data_noallay2$condition3)

# specify the model that predicts the mediator
model_med = lm(w2.article_feel_6 ~ condition3 + gender + racialresentment + ideology + education + income + age + partyidentification, data = data_noallay2)

set.seed(235)
# fair point
model_out_fairpt = lm(w2.flyer_fairpt ~ condition3 * w2.article_feel_6 + gender + racialresentment + ideology + education + income + age + partyidentification, data=data_noallay2)
model_combo_fairpt = mediation::mediate(model_med, model_out_fairpt, treat="condition3", mediator="w2.article_feel_6", sims=1000)
summary(model_combo_fairpt)

# vote
model_out_vote = lm(w2.flyer_vote ~ condition3 * w2.article_feel_6 + gender + racialresentment + ideology + education + income + age + partyidentification, data=data_noallay2)
model_combo_vote = mediation::mediate(model_med, model_out_vote, treat="condition3", mediator="w2.article_feel_6", sims=1000)
summary(model_combo_vote)

# offend
model_out_offend = lm(w2.flyer_offend ~ condition3 * w2.article_feel_6 + gender + racialresentment + partyidentification + ideology + education + income + age, data=data_noallay2)
model_combo_offend = mediation::mediate(model_med, model_out_offend, treat="condition3", mediator="w2.article_feel_6", sims=1000)
summary(model_combo_offend)

# insensitive
model_out_insens = lm(w2.flyer_insens ~ condition3 * w2.article_feel_6 + gender + racialresentment + partyidentification + ideology + education + income + age, data=data_noallay2)
model_combo_insens = mediation::mediate(model_med, model_out_insens, treat="condition3", mediator="w2.article_feel_6", sims=1000)
summary(model_combo_insens)

# agree
model_out_agree = lm(w2.flyer_agree ~ condition3 * w2.article_feel_6 + gender + racialresentment + partyidentification + ideology + education + income + age, data=data_noallay2)
model_combo_agree = mediation::mediate(model_med, model_out_agree, treat="condition3", mediator="w2.article_feel_6", sims=1000)
summary(model_combo_agree)

### Mediator: Felt threat scale 
data_noallay2 <- data_noallay
data_noallay2 <- data_noallay2[,c("w2.article_feel_combo_anxiety3", "condition3", "w2.flyer_agree", "w2.flyer_insens", "w2.flyer_fairpt", "w2.flyer_offend", "w2.flyer_conflict", "w2.flyer_vote", "racialresentment", "gender", "partyidentification", "ideology", "education", "income", "age")]
data_noallay2 <- data_noallay2[complete.cases(data_noallay2), ]

# ensure treatment indicator is a factor variable
data_noallay2$condition3 <- as.factor(data_noallay2$condition3)

# first, specify the model that predicts the mediator
model_med = lm(w2.article_feel_combo_anxiety3 ~ condition3 + gender + racialresentment + ideology + education + income + age + partyidentification, data = data_noallay2)

set.seed(235)

# fair point
model_out_fairpt = lm(w2.flyer_fairpt ~ condition3 * w2.article_feel_combo_anxiety3 + gender + racialresentment + ideology + education + income + age + partyidentification, data=data_noallay2)
model_combo_fairpt = mediation::mediate(model_med, model_out_fairpt, treat="condition3", mediator="w2.article_feel_combo_anxiety3", sims=1000)
summary(model_combo_fairpt)

# vote
model_out_vote = lm(w2.flyer_vote ~ condition3 * w2.article_feel_combo_anxiety3 + gender + racialresentment + ideology + education + income + age + partyidentification, data=data_noallay2)
model_combo_vote = mediation::mediate(model_med, model_out_vote, treat="condition3", mediator="w2.article_feel_combo_anxiety3", sims=1000)
summary(model_combo_vote)

# offend
model_out_offend = lm(w2.flyer_offend ~ condition3 * w2.article_feel_combo_anxiety3 + gender + racialresentment + partyidentification + ideology + education + income + age, data=data_noallay2)
model_combo_offend = mediation::mediate(model_med, model_out_offend, treat="condition3", mediator="w2.article_feel_combo_anxiety3", sims=1000)
summary(model_combo_offend)

# insensitive
model_out_insens = lm(w2.flyer_insens ~ condition3 * w2.article_feel_combo_anxiety3 + gender + racialresentment + partyidentification + ideology + education + income + age, data=data_noallay2)
model_combo_insens = mediation::mediate(model_med, model_out_insens, treat="condition3", mediator="w2.article_feel_combo_anxiety3", sims=1000)
summary(model_combo_insens)

# agree
model_out_agree = lm(w2.flyer_agree ~ condition3 * w2.article_feel_combo_anxiety3 + gender + racialresentment + partyidentification + ideology + education + income + age, data=data_noallay2)
model_combo_agree = mediation::mediate(model_med, model_out_agree, treat="condition3", mediator="w2.article_feel_combo_anxiety3", sims=1000)
summary(model_combo_agree)


# Figure 4: ACME plot
models <- c("1. Fair Point", "2. Vote", "3. Offend", "4. Insensitive", "5. Agree")
acmes <- c(model_combo_fairpt$d1, model_combo_vote$d1, model_combo_offend$d1, 
           model_combo_insens$d1, model_combo_agree$d1)
acmes_lower <- c(model_combo_fairpt$d1.ci[1], model_combo_vote$d1.ci[1], model_combo_offend$d1.ci[1],
                 model_combo_insens$d1.ci[1], model_combo_agree$d1.ci[1])
acmes_upper <- c(model_combo_fairpt$d1.ci[2], model_combo_vote$d1.ci[2], model_combo_offend$d1.ci[2], 
                 model_combo_insens$d1.ci[2], model_combo_agree$d1.ci[2])

df <- as.data.frame(cbind(acmes, acmes_lower, acmes_upper))
df <- cbind(df, models)
View(df)

pdf("medacmes.pdf", width=7, height=4)
med_acmes <- ggplot(df, aes(models, acmes)) + geom_point() + geom_pointrange(aes(ymin=acmes_lower, ymax=acmes_upper)) + geom_hline(yintercept=0, linetype="dashed") + theme_bw() + labs(x="Model", y="ACME")+ theme(text = element_text(size=16),axis.text.x = element_text(size=14, angle=45, hjust = 1),axis.text.y = element_text(size=18))
med_acmes
dev.off()




##########################################################################################################################
######
######### Appendix A: Question wording/survey
######

######
######### Appendix B: Descriptive Statistics and Additional Tests
######

# Table B1 
mins <- cbind(min(data$partyidentification[data$w2_chr_stthreat!=""], na.rm=T),
              min(data$ideology[data$w2_chr_stthreat!=""], na.rm=T),
              min(data$education[data$w2_chr_stthreat!=""], na.rm=T),
              min(data$age[data$w2_chr_stthreat!=""], na.rm=T),
              min(data$income[data$w2_chr_stthreat!=""], na.rm=T))
maxs <- cbind(max(data$partyidentification[data$w2_chr_stthreat!=""], na.rm=T),
              max(data$ideology[data$w2_chr_stthreat!=""], na.rm=T),
              max(data$education[data$w2_chr_stthreat!=""], na.rm=T),
              max(data$age[data$w2_chr_stthreat!=""], na.rm=T),
              max(data$income[data$w2_chr_stthreat!=""], na.rm=T))
means <- cbind(mean(data$partyidentification[data$w2_chr_stthreat!=""], na.rm=T),
               mean(data$ideology[data$w2_chr_stthreat!=""], na.rm=T),
               mean(data$education[data$w2_chr_stthreat!=""], na.rm=T),
               mean(data$age[data$w2_chr_stthreat!=""], na.rm=T),
               mean(data$income[data$w2_chr_stthreat!=""], na.rm=T))
sds <- cbind(sd(data$partyidentification[data$w2_chr_stthreat!=""], na.rm=T),
             sd(data$ideology[data$w2_chr_stthreat!=""], na.rm=T),
             sd(data$education[data$w2_chr_stthreat!=""], na.rm=T),
             sd(data$age[data$w2_chr_stthreat!=""], na.rm=T),
             sd(data$income[data$w2_chr_stthreat!=""], na.rm=T))
ns <- cbind(sum(!is.na(data$partyidentification[data$w2_chr_stthreat!=""])),
            sum(!is.na(data$ideology[data$w2_chr_stthreat!=""])),
            sum(!is.na(data$education[data$w2_chr_stthreat!=""])),
            sum(!is.na(data$age[data$w2_chr_stthreat!=""])),
            sum(!is.na(data$income[data$w2_chr_stthreat!=""])))
tab <- xtable(t(rbind(ns, means, sds, mins, maxs)))

names <- c("N", "Mean", "SD", "Min", "Max")

names(tab) <- names
rownames(tab) <- c("Party Identification", "Ideology", "Education", "Age", "Income")
tab
xtable(tab, digits=2)

# Table B2
mins <- cbind(min(data$w2.flyer_fairpt, na.rm=T), min(data$w2.flyer_insens, na.rm=T), 
              min(data$w2.flyer_agree, na.rm=T), min(data$w2.flyer_offend, na.rm=T), 
              min(data$w2.flyer_vote, na.rm=T), min(data$w2.article_feel_1, na.rm=T), 
              min(data$w2.article_feel_2, na.rm=T),  min(data$w2.article_feel_3, na.rm=T), 
              min(data$w2.article_feel_4, na.rm=T),  min(data$w2.article_feel_5, na.rm=T), 
              min(data$w2.article_feel_6, na.rm=T),  min(data$w2.article_feel_combo_anxiety3, na.rm=T))
maxs <- cbind(max(data$w2.flyer_fairpt, na.rm=T), max(data$w2.flyer_insens, na.rm=T), 
              max(data$w2.flyer_agree, na.rm=T), max(data$w2.flyer_offend, na.rm=T), 
              max(data$w2.flyer_vote, na.rm=T), max(data$w2.article_feel_1, na.rm=T), 
              max(data$w2.article_feel_2, na.rm=T),  max(data$w2.article_feel_3, na.rm=T), 
              max(data$w2.article_feel_4, na.rm=T),  max(data$w2.article_feel_5, na.rm=T), 
              max(data$w2.article_feel_6, na.rm=T),  max(data$w2.article_feel_combo_anxiety3, na.rm=T))
means <- cbind(mean(data$w2.flyer_fairpt, na.rm=T), mean(data$w2.flyer_insens, na.rm=T), 
               mean(data$w2.flyer_agree, na.rm=T), mean(data$w2.flyer_offend, na.rm=T), 
               mean(data$w2.flyer_vote, na.rm=T), mean(data$w2.article_feel_1, na.rm=T), 
               mean(data$w2.article_feel_2, na.rm=T), mean(data$w2.article_feel_3, na.rm=T), 
               mean(data$w2.article_feel_4, na.rm=T), mean(data$w2.article_feel_5, na.rm=T), 
               mean(data$w2.article_feel_6, na.rm=T), mean(data$w2.article_feel_combo_anxiety3, na.rm=T))
sds <- cbind(sd(data$w2.flyer_fairpt, na.rm=T), sd(data$w2.flyer_insens, na.rm=T), 
             sd(data$w2.flyer_agree, na.rm=T), sd(data$w2.flyer_offend, na.rm=T), 
             sd(data$w2.flyer_vote, na.rm=T), sd(data$w2.article_feel_1, na.rm=T), 
             sd(data$w2.article_feel_2, na.rm=T), sd(data$w2.article_feel_3, na.rm=T), 
             sd(data$w2.article_feel_4, na.rm=T), sd(data$w2.article_feel_5, na.rm=T), 
             sd(data$w2.article_feel_6, na.rm=T), sd(data$w2.article_feel_combo_anxiety3, na.rm=T))
ns <- cbind(sum(!is.na(data$w2.flyer_fairpt)), sum(!is.na(data$w2.flyer_insens)), 
            sum(!is.na(data$w2.flyer_agree)), sum(!is.na(data$w2.flyer_offend)), 
            sum(!is.na(data$w2.flyer_vote)), sum(!is.na(data$w2.article_feel_1)), 
            sum(!is.na(data$w2.article_feel_2)), sum(!is.na(data$w2.article_feel_3)), 
            sum(!is.na(data$w2.article_feel_4)), sum(!is.na(data$w2.article_feel_5)), 
            sum(!is.na(data$w2.article_feel_6)), sum(!is.na(data$w2.article_feel_combo_anxiety3)))
names <- c("N", "Mean", "SD", "Min", "Max")

tab <- xtable(t(rbind(ns, means, sds, mins, maxs)))
names(tab) <- names
rownames(tab) <- c("Flyer: Fair point", "Flyer: Insensitive", "Flyer: Agree","Flyer: Offend", "Flyer: Vote", "Article: Anxiety", "Article: Pride", "Article: Anger", "Article: Hope", "Article: Worry", "Article: Excitement", "Article: Negative Emotions Scale")
tab

# Figure B2
pdf("histogram_rr.pdf")
hist(data$racialresentment[data$w2_wave2==1], main="", xlab="Racial Resentment", col="gray",cex.lab=1.5, cex.axis=1.5)
dev.off()

# B.3: Power Test 
data_noallay2 <- data_noallay
data_noallay2 <- data_noallay2[,c("w2.article_feel_combo_anxiety3", "condition_2", "w2.flyer_agree", "w2.flyer_insens", "w2.flyer_fairpt", "w2.flyer_offend", "w2.flyer_conflict", "w2.flyer_vote", "racialresentment", "gender", "partyidentification", "ideology", "education", "income", "age")]
data_noallay2 <- data_noallay2[complete.cases(data_noallay2), ]

data_noallay2$condition_2 <- as.factor(data_noallay2$condition_2)

model_med = lm(w2.article_feel_combo_anxiety3 ~ condition_2 + gender + racialresentment + ideology + education + income + age + partyidentification, data = data_noallay2)
summary(model_med)
model_out_fairpt = lm(w2.flyer_fairpt ~ condition_2 * w2.article_feel_combo_anxiety3 + gender + racialresentment + ideology + education + income + age + partyidentification, data=data_noallay2)
summary(model_out_fairpt)
sd(data$condition_2, na.rm=T)
sd(data$w2.article_feel_combo_anxiety3, na.rm=T)
cor(data$w2.article_feel_combo_anxiety3, data$condition_2, use="complete.obs")

power = powerMediation::powerMediation.Sobel(n=391, 
                                             theta.1a = -0.5888671, 
                                             lambda.a = 0.401274, 
                                             sigma.x = 0.8226063,
                                             sigma.m = 1.078545,
                                             sigma.epsilon = 1.223,
                                             alpha=0.05,
                                             verbose=TRUE)
power$power
power$delta
power2 = powerMediation::powerMediation.VSMc(n=391, 
                                             b2 = 0.401274, 
                                             sigma.m = 1.078545,
                                             sigma.e = 1.223,
                                             corr.xm = -0.1858647, 
                                             alpha=0.05,
                                             verbose=TRUE)
power2$power
power2$delta

# B.4: Anxiety development in the control condition 
data_controlonly = subset(data_noallay, data_noallay$condition_name=="Control")
data_controlonly = subset(data_controlonly, data_controlonly$pid_naive!="NA")

surv1density_binnedrr2 <- ggplot(data=data_controlonly, aes(x=w2.article_feel_1, 
                                                            group=rr_bin,
                                                            linetype=rr_bin)) +
  geom_density() + theme_classic()+
  scale_linetype_manual(values=c("solid","dotted", "dashed"))+
  labs(title="",x="Anxiety", y = "Density") + theme(legend.title=element_blank(), 
                                                    plot.title = element_text(hjust = 0.5),
                                                    text = element_text(size=24), axis.text.x = element_text(size=22), 
                                                    axis.text.y = element_text(size=26))

surv1density_binnedrr2

pdf("surv1density_binnedrr2.pdf")
surv1density_binnedrr2
dev.off()

surv1density_binnedpid2 = ggplot(data=data_controlonly, aes(x=w2.article_feel_1, 
                                                            group=pid_naive,
                                                            linetype=pid_naive)) +
  geom_density()+ theme_classic() + 
  scale_linetype_manual(values=c("solid","dotted", "dashed")) + 
  labs(title="",x="Anxiety", y = "Density") + theme(legend.title=element_blank(), 
                                                    plot.title = element_text(hjust = 0.5),
                                                    text = element_text(size=24), axis.text.x = element_text(size=22), 
                                                    axis.text.y = element_text(size=26))
surv1density_binnedpid2

pdf("surv1density_binnedpid2.pdf")
surv1density_binnedpid2
dev.off()

# B.5: Manipulation check
manip <- lm(w2.article_stthreat ~ as.factor(condition) + stthreat, data=data)
texreg(list(manip), digits=2, stars = c(0.05, 0.01))

manip1 <- lm(w2.article_feel_1 ~ as.factor(condition), data=data)
manip2 <- lm(w2.article_feel_2 ~ as.factor(condition), data=data)
manip3 <- lm(w2.article_feel_3 ~ as.factor(condition), data=data)
manip4 <- lm(w2.article_feel_4 ~ as.factor(condition), data=data)
manip5 <- lm(w2.article_feel_5 ~ as.factor(condition), data=data)
manip6 <- lm(w2.article_feel_6 ~ as.factor(condition), data=data)

texreg(list(manip1,manip2,manip3,manip4,manip5,manip6), digits=2, stars = c(0.05, 0.01))

# B.6: Balance check
b1=(lm(partyidentification ~ as.factor(condition_name), data=data))
b2=(lm(ideology ~ as.factor(condition_name), data=data))
b3=(lm(racialresentment ~ as.factor(condition_name), data=data))
b4=(lm(education ~ as.factor(condition_name), data=data)) # there is a sig effect here 
b5=(lm(income ~ as.factor(condition_name), data=data))
b6=(lm(gender ~ as.factor(condition_name), data=data))
b7=(lm(age ~ as.factor(condition_name), data=data))
texreg(list(b1,b2,b3,b4,b5,b6,b7), digits=2, stars=c(0.05, 0.01))

# B.7 Emotional responses to the explicit appeal
t.test(data_noallay$w2.flyer_feels_1[data_noallay$condition=="Control"], 
       data_noallay$w2.flyer_feels_1[data_noallay$condition=="ST_Treatment1"])
t.test(data_noallay$w2.flyer_feels_2[data_noallay$condition=="Control"], 
       data_noallay$w2.flyer_feels_2[data_noallay$condition=="ST_Treatment1"])
t.test(data_noallay$w2.flyer_feels_3[data_noallay$condition=="Control"], 
       data_noallay$w2.flyer_feels_3[data_noallay$condition=="ST_Treatment1"])
t.test(data_noallay$w2.flyer_feels_4[data_noallay$condition=="Control"], 
       data_noallay$w2.flyer_feels_4[data_noallay$condition=="ST_Treatment1"])
t.test(data_noallay$w2.flyer_feels_5[data_noallay$condition=="Control"], 
       data_noallay$w2.flyer_feels_5[data_noallay$condition=="ST_Treatment1"])
t.test(data_noallay$w2.flyer_feels_6[data_noallay$condition=="Control"], 
       data_noallay$w2.flyer_feels_6[data_noallay$condition=="ST_Treatment1"])

# B.8 Sensitivity tests for mediation models
# Note: For models with felt threat scale as mediator -- rerun models before specifying sensitivity tests
sensout_fairpt <- mediation::medsens(model_combo_fairpt, sims=1000, rho.by=.01)
summary(sensout_fairpt)

sensout_vote <- mediation::medsens(model_combo_vote, sims=1000, rho.by=.01)
summary(sensout_vote)

sensout_agree <- mediation::medsens(model_combo_agree, sims=1000, rho.by=.01)
summary(sensout_agree)

pdf("sens_plot_fairpt.pdf", width=7, height=4)
par(mfrow=c(1,2))
plot(sensout_fairpt, ylim=c(-2,2))
dev.off()

pdf("sens_plot_vote.pdf", width=7, height=4)
par(mfrow=c(1,2))
plot(sensout_vote, ylim=c(-2,2))
dev.off()

pdf("sens_plot_agree.pdf", width=7, height=4)
par(mfrow=c(1,2))
plot(sensout_agree, ylim=c(-2,2))
dev.off()

# B.9: Resentment as moderator for explicit appeal acceptance
model_fairpt = lm(w2.flyer_fairpt ~ as.factor(condition)*racialresentment, data=data)
model_agree = lm(w2.flyer_agree ~ as.factor(condition)*racialresentment, data=data)
model_insens = lm(w2.flyer_insens ~ as.factor(condition)*racialresentment, data=data)
model_offend = lm(w2.flyer_offend ~ as.factor(condition)*racialresentment, data=data)
model_vote = lm(w2.flyer_vote ~ as.factor(condition)*racialresentment, data=data)
texreg(list(model_fairpt, model_agree, model_insens, model_offend, model_vote), digits=2, stars = c(0.05))

######
######### Appendix C: Full Models 
######

# C.1 through C.8: Inserted from running them (in earlier code)

# C.9 Regression-style mediation
# Table C37
app_med1 = (lm(w2.flyer_fairpt ~ as.factor(condition3) + w2.article_feel_1 + w2.article_feel_3 + w2.article_feel_5 + gender + racialresentment + ideology + education + income + age + partyidentification, data=data_noallay))
app_med2 = (lm(w2.flyer_vote ~ as.factor(condition3) + w2.article_feel_1 + w2.article_feel_3 + w2.article_feel_5 + gender + racialresentment + ideology + education + income + age + partyidentification, data=data_noallay))
app_med3 = (lm(w2.flyer_offend ~ as.factor(condition3) + w2.article_feel_1 + w2.article_feel_3 + w2.article_feel_5 + gender + racialresentment + ideology + education + income + age + partyidentification, data=data_noallay))
app_med4 = (lm(w2.flyer_insens ~ as.factor(condition3) + w2.article_feel_1 + w2.article_feel_3 + w2.article_feel_5 + gender + racialresentment + ideology + education + income + age + partyidentification, data=data_noallay))
app_med5 = (lm(w2.flyer_agree ~ as.factor(condition3) + w2.article_feel_1 + w2.article_feel_3 + w2.article_feel_5 + gender + racialresentment + ideology + education + income + age + partyidentification, data=data_noallay))
texreg(list(app_med1, app_med2, app_med3, app_med4, app_med5), stars = c(0.1, 0.05, 0.01))

# Table C38
app_med1_m1 = (lm(w2.article_feel_1 ~ as.factor(condition3) + gender + racialresentment + ideology + education + income + age + partyidentification, data=data_noallay))
app_med1_m2 = (lm(w2.article_feel_3 ~ as.factor(condition3) + gender + racialresentment + ideology + education + income + age + partyidentification, data=data_noallay))
app_med1_m3 = (lm(w2.article_feel_5 ~ as.factor(condition3) + gender + racialresentment + ideology + education + income + age + partyidentification, data=data_noallay))
texreg(list(app_med1_m1, app_med1_m2, app_med1_m3), stars = c(0.1, 0.05, 0.01))

# Table C39
app_med1_effect = app_med1$coefficients[3]*app_med1_m1$coefficients[2] + 
  app_med1$coefficients[4]*app_med1_m2$coefficients[2] + app_med1$coefficients[5]*app_med1_m3$coefficients[2]
app_med2_effect = app_med2$coefficients[3]*app_med1_m1$coefficients[2] + 
  app_med2$coefficients[4]*app_med1_m2$coefficients[2] + app_med2$coefficients[5]*app_med1_m3$coefficients[2]
app_med3_effect = app_med3$coefficients[3]*app_med1_m1$coefficients[2] + 
  app_med3$coefficients[4]*app_med1_m2$coefficients[2] + app_med3$coefficients[5]*app_med1_m3$coefficients[2]
app_med4_effect = app_med4$coefficients[3]*app_med1_m1$coefficients[2] + 
  app_med4$coefficients[4]*app_med1_m2$coefficients[2] + app_med4$coefficients[5]*app_med1_m3$coefficients[2]
app_med5_effect = app_med5$coefficients[3]*app_med1_m1$coefficients[2] + 
  app_med5$coefficients[4]*app_med1_m2$coefficients[2] + app_med5$coefficients[5]*app_med1_m3$coefficients[2]

# C.10 Subgroup analyses
# C.10.1: Partisanship: Democrats
democrats = subset(data_noallay, data_noallay$pid_naive == "Democrat")

democrats2 <- democrats[,c("w2.article_feel_combo_anxiety3", "condition3", "w2.flyer_agree", "w2.flyer_insens", "w2.flyer_fairpt", "w2.flyer_offend", "w2.flyer_conflict", "w2.flyer_vote", "racialresentment", "gender", "partyidentification", "ideology", "education", "income", "age")]
democrats2 <- democrats2[complete.cases(democrats2), ]

model_med = lm(w2.article_feel_combo_anxiety3 ~ condition3 + gender + racialresentment + ideology + education + income + age + partyidentification, data = democrats2)

set.seed(235)
# fair point
model_out_fairpt = lm(w2.flyer_fairpt ~ condition3 * w2.article_feel_combo_anxiety3 + gender + racialresentment + ideology + education + income + age + partyidentification, data=democrats2)
model_combo_fairpt = mediation::mediate(model_med, model_out_fairpt, treat="condition3", mediator="w2.article_feel_combo_anxiety3", sims=1000)
summary(model_combo_fairpt)

# vote
model_out_vote = lm(w2.flyer_vote ~ condition3 * w2.article_feel_combo_anxiety3 + gender + racialresentment + ideology + education + income + age + partyidentification, data=democrats2)
model_combo_vote = mediation::mediate(model_med, model_out_vote, treat="condition3", mediator="w2.article_feel_combo_anxiety3", sims=1000)
summary(model_combo_vote)

# offend
model_out_offend = lm(w2.flyer_offend ~ condition3 * w2.article_feel_combo_anxiety3 + gender + racialresentment + partyidentification + ideology + education + income + age, data=democrats2)
model_combo_offend = mediation::mediate(model_med, model_out_offend, treat="condition3", mediator="w2.article_feel_combo_anxiety3", sims=1000)
summary(model_combo_offend)

# insensitive
model_out_insens = lm(w2.flyer_insens ~ condition3 * w2.article_feel_combo_anxiety3 + gender + racialresentment + partyidentification + ideology + education + income + age, data=democrats2)
model_combo_insens = mediation::mediate(model_med, model_out_insens, treat="condition3", mediator="w2.article_feel_combo_anxiety3", sims=1000)
summary(model_combo_insens)

# agree
model_out_agree = lm(w2.flyer_agree ~ condition3 * w2.article_feel_combo_anxiety3 + gender + racialresentment + partyidentification + ideology + education + income + age, data=democrats2)
model_combo_agree = mediation::mediate(model_med, model_out_agree, treat="condition3", mediator="w2.article_feel_combo_anxiety3", sims=1000)
summary(model_combo_agree)

# C.10.2: Partisanship: Republicans
republicans = subset(data_noallay, data_noallay$pid_naive == "Republican")

republicans2 <- republicans[,c("w2.article_feel_combo_anxiety3", "condition3", "w2.flyer_agree", "w2.flyer_insens", "w2.flyer_fairpt", "w2.flyer_offend", "w2.flyer_conflict", "w2.flyer_vote", "racialresentment", "gender", "partyidentification", "ideology", "education", "income", "age")]
republicans2 <- republicans2[complete.cases(republicans2), ]

model_med = lm(w2.article_feel_combo_anxiety3 ~ condition3 + gender + racialresentment + ideology + education + income + age + partyidentification, data = republicans2)

set.seed(235)
# fair point
model_out_fairpt = lm(w2.flyer_fairpt ~ condition3 * w2.article_feel_combo_anxiety3 + gender + racialresentment + ideology + education + income + age + partyidentification, data=republicans2)
model_combo_fairpt = mediation::mediate(model_med, model_out_fairpt, treat="condition3", mediator="w2.article_feel_combo_anxiety3", sims=1000)
summary(model_combo_fairpt)

# vote
model_out_vote = lm(w2.flyer_vote ~ condition3 * w2.article_feel_combo_anxiety3 + gender + racialresentment + ideology + education + income + age + partyidentification, data=republicans2)
model_combo_vote = mediation::mediate(model_med, model_out_vote, treat="condition3", mediator="w2.article_feel_combo_anxiety3", sims=1000)
summary(model_combo_vote)

# offend
model_out_offend = lm(w2.flyer_offend ~ condition3 * w2.article_feel_combo_anxiety3 + gender + racialresentment + partyidentification + ideology + education + income + age, data=republicans2)
model_combo_offend = mediation::mediate(model_med, model_out_offend, treat="condition3", mediator="w2.article_feel_combo_anxiety3", sims=1000)
summary(model_combo_offend)

# insensitive
model_out_insens = lm(w2.flyer_insens ~ condition3 * w2.article_feel_combo_anxiety3 + gender + racialresentment + partyidentification + ideology + education + income + age, data=republicans2)
model_combo_insens = mediation::mediate(model_med, model_out_insens, treat="condition3", mediator="w2.article_feel_combo_anxiety3", sims=1000)
summary(model_combo_insens)

# agree
model_out_agree = lm(w2.flyer_agree ~ condition3 * w2.article_feel_combo_anxiety3 + gender + racialresentment + partyidentification + ideology + education + income + age, data=republicans2)
model_combo_agree = mediation::mediate(model_med, model_out_agree, treat="condition3", mediator="w2.article_feel_combo_anxiety3", sims=1000)
summary(model_combo_agree)

# Table C50
app_medrep1 = (lm(w2.flyer_fairpt ~ as.factor(condition3) + w2.article_feel_1 + w2.article_feel_3 + w2.article_feel_5 + gender + racialresentment + ideology + education + income + age + partyidentification, data=republicans))
app_medrep2 = (lm(w2.flyer_vote ~ as.factor(condition3) + w2.article_feel_1 + w2.article_feel_3 + w2.article_feel_5 + gender + racialresentment + ideology + education + income + age + partyidentification, data=republicans))
app_medrep3 = (lm(w2.flyer_offend ~ as.factor(condition3) + w2.article_feel_1 + w2.article_feel_3 + w2.article_feel_5 + gender + racialresentment + ideology + education + income + age + partyidentification, data=republicans))
app_medrep4 = (lm(w2.flyer_insens ~ as.factor(condition3) + w2.article_feel_1 + w2.article_feel_3 + w2.article_feel_5 + gender + racialresentment + ideology + education + income + age + partyidentification, data=republicans))
app_medrep5 = (lm(w2.flyer_agree ~ as.factor(condition3) + w2.article_feel_1 + w2.article_feel_3 + w2.article_feel_5 + gender + racialresentment + ideology + education + income + age + partyidentification, data=republicans))
texreg(list(app_medrep1, app_medrep2, app_medrep3, app_medrep4, app_medrep5), stars=c(0.1, 0.05, 0.01))

# Table C51
app_medrep1_m1 = (lm(w2.article_feel_1 ~ as.factor(condition3) + gender + racialresentment + ideology + education + income + age + partyidentification, data=republicans))
app_medrep1_m2 = (lm(w2.article_feel_3 ~ as.factor(condition3) + gender + racialresentment + ideology + education + income + age + partyidentification, data=republicans))
app_medrep1_m3 = (lm(w2.article_feel_5 ~ as.factor(condition3) + gender + racialresentment + ideology + education + income + age + partyidentification, data=republicans))
texreg(list(app_medrep1_m1, app_medrep1_m2, app_medrep1_m3), stars = c(0.1, 0.05, 0.01))

# Table C52
app_medrep1_effect = app_medrep1$coefficients[3]*app_medrep1_m1$coefficients[2] + 
  app_medrep1$coefficients[4]*app_medrep1_m2$coefficients[2] + app_medrep1$coefficients[5]*app_medrep1_m3$coefficients[2]
app_medrep2_effect = app_medrep2$coefficients[3]*app_medrep1_m1$coefficients[2] + 
  app_medrep2$coefficients[4]*app_medrep1_m2$coefficients[2] + app_medrep2$coefficients[5]*app_medrep1_m3$coefficients[2]
app_medrep3_effect = app_medrep3$coefficients[3]*app_medrep1_m1$coefficients[2] + 
  app_medrep3$coefficients[4]*app_medrep1_m2$coefficients[2] + app_medrep3$coefficients[5]*app_medrep1_m3$coefficients[2]
app_medrep4_effect = app_medrep4$coefficients[3]*app_medrep1_m1$coefficients[2] + 
  app_medrep4$coefficients[4]*app_medrep1_m2$coefficients[2] + app_medrep4$coefficients[5]*app_medrep1_m3$coefficients[2]
app_medrep5_effect = app_medrep5$coefficients[3]*app_medrep1_m1$coefficients[2] + 
  app_medrep5$coefficients[4]*app_medrep1_m2$coefficients[2] + app_medrep5$coefficients[5]*app_medrep1_m3$coefficients[2]

# C10.3 Levels of racial resentment: Lower RR
lowrr = subset(data_noallay, data_noallay$rr_bin == "Lower RR")

lowrr2 <- lowrr[,c("w2.article_feel_combo_anxiety3", "condition3", "w2.flyer_agree", "w2.flyer_insens", "w2.flyer_fairpt", "w2.flyer_offend", "w2.flyer_conflict", "w2.flyer_vote", "racialresentment", "gender", "partyidentification", "ideology", "education", "income", "age")]
lowrr2 <- lowrr2[complete.cases(lowrr2), ]

model_med = lm(w2.article_feel_combo_anxiety3 ~ condition3 + gender + racialresentment + ideology + education + income + age + partyidentification, data = lowrr2)

set.seed(235)
# fair point
model_out_fairpt = lm(w2.flyer_fairpt ~ condition3 * w2.article_feel_combo_anxiety3 + gender + racialresentment + ideology + education + income + age + partyidentification, data=lowrr2)
model_combo_fairpt = mediation::mediate(model_med, model_out_fairpt, treat="condition3", mediator="w2.article_feel_combo_anxiety3", sims=1000)
summary(model_combo_fairpt)

# vote
model_out_vote = lm(w2.flyer_vote ~ condition3 * w2.article_feel_combo_anxiety3 + gender + racialresentment + ideology + education + income + age + partyidentification, data=lowrr2)
model_combo_vote = mediation::mediate(model_med, model_out_vote, treat="condition3", mediator="w2.article_feel_combo_anxiety3", sims=1000)
summary(model_combo_vote)

# offend
model_out_offend = lm(w2.flyer_offend ~ condition3 * w2.article_feel_combo_anxiety3 + gender + racialresentment + partyidentification + ideology + education + income + age, data=lowrr2)
model_combo_offend = mediation::mediate(model_med, model_out_offend, treat="condition3", mediator="w2.article_feel_combo_anxiety3", sims=1000)
summary(model_combo_offend)

# insensitive
model_out_insens = lm(w2.flyer_insens ~ condition3 * w2.article_feel_combo_anxiety3 + gender + racialresentment + partyidentification + ideology + education + income + age, data=lowrr2)
model_combo_insens = mediation::mediate(model_med, model_out_insens, treat="condition3", mediator="w2.article_feel_combo_anxiety3", sims=1000)
summary(model_combo_insens)

# agree
model_out_agree = lm(w2.flyer_agree ~ condition3 * w2.article_feel_combo_anxiety3 + gender + racialresentment + partyidentification + ideology + education + income + age, data=lowrr2)
model_combo_agree = mediation::mediate(model_med, model_out_agree, treat="condition3", mediator="w2.article_feel_combo_anxiety3", sims=1000)
summary(model_combo_agree)

# C.10.4 Levels of racial resentment: Medium RR
medrr = subset(data_noallay, data_noallay$rr_bin == "Medium RR")

medrr2 <- medrr[,c("w2.article_feel_combo_anxiety3", "condition3", "w2.flyer_agree", "w2.flyer_insens", "w2.flyer_fairpt", "w2.flyer_offend", "w2.flyer_conflict", "w2.flyer_vote", "racialresentment", "gender", "partyidentification", "ideology", "education", "income", "age")]
medrr2 <- medrr2[complete.cases(medrr2), ]

model_med = lm(w2.article_feel_combo_anxiety3 ~ condition3 + gender + racialresentment + ideology + education + income + age + partyidentification, data = medrr2)

set.seed(235)
# fair point
model_out_fairpt = lm(w2.flyer_fairpt ~ condition3 * w2.article_feel_combo_anxiety3 + gender + racialresentment + ideology + education + income + age + partyidentification, data=medrr2)
model_combo_fairpt = mediation::mediate(model_med, model_out_fairpt, treat="condition3", mediator="w2.article_feel_combo_anxiety3", sims=1000)
summary(model_combo_fairpt)

# vote
model_out_vote = lm(w2.flyer_vote ~ condition3 * w2.article_feel_combo_anxiety3 + gender + racialresentment + ideology + education + income + age + partyidentification, data=medrr2)
model_combo_vote = mediation::mediate(model_med, model_out_vote, treat="condition3", mediator="w2.article_feel_combo_anxiety3", sims=1000)
summary(model_combo_vote)

# offend
model_out_offend = lm(w2.flyer_offend ~ condition3 * w2.article_feel_combo_anxiety3 + gender + racialresentment + partyidentification + ideology + education + income + age, data=medrr2)
model_combo_offend = mediation::mediate(model_med, model_out_offend, treat="condition3", mediator="w2.article_feel_combo_anxiety3", sims=1000)
summary(model_combo_offend)

# insensitive
model_out_insens = lm(w2.flyer_insens ~ condition3 * w2.article_feel_combo_anxiety3 + gender + racialresentment + partyidentification + ideology + education + income + age, data=medrr2)
model_combo_insens = mediation::mediate(model_med, model_out_insens, treat="condition3", mediator="w2.article_feel_combo_anxiety3", sims=1000)
summary(model_combo_insens)

# agree
model_out_agree = lm(w2.flyer_agree ~ condition3 * w2.article_feel_combo_anxiety3 + gender + racialresentment + partyidentification + ideology + education + income + age, data=medrr2)
model_combo_agree = mediation::mediate(model_med, model_out_agree, treat="condition3", mediator="w2.article_feel_combo_anxiety3", sims=1000)
summary(model_combo_agree)

# Table C63
app_med_medrr1 = (lm(w2.flyer_fairpt ~ as.factor(condition3) + w2.article_feel_1 + w2.article_feel_3 + w2.article_feel_5 + gender + racialresentment + ideology + education + income + age + partyidentification, data=medrr))
app_med_medrr2 = (lm(w2.flyer_vote ~ as.factor(condition3) + w2.article_feel_1 + w2.article_feel_3 + w2.article_feel_5 + gender + racialresentment + ideology + education + income + age + partyidentification, data=medrr))
app_med_medrr3 = (lm(w2.flyer_offend ~ as.factor(condition3) + w2.article_feel_1 + w2.article_feel_3 + w2.article_feel_5 + gender + racialresentment + ideology + education + income + age + partyidentification, data=medrr))
app_med_medrr4 = (lm(w2.flyer_insens ~ as.factor(condition3) + w2.article_feel_1 + w2.article_feel_3 + w2.article_feel_5 + gender + racialresentment + ideology + education + income + age + partyidentification, data=medrr))
app_med_medrr5 = (lm(w2.flyer_agree ~ as.factor(condition3) + w2.article_feel_1 + w2.article_feel_3 + w2.article_feel_5 + gender + racialresentment + ideology + education + income + age + partyidentification, data=medrr))
texreg(list(app_med_medrr1, app_med_medrr2, app_med_medrr3, app_med_medrr4, app_med_medrr5), stars=c(0.1, 0.05, 0.01))

# Table C64
app_med1_medrrm1 = (lm(w2.article_feel_1 ~ as.factor(condition3) + gender + racialresentment + ideology + education + income + age + partyidentification, data=medrr))
app_med1_medrrm2 = (lm(w2.article_feel_3 ~ as.factor(condition3) + gender + racialresentment + ideology + education + income + age + partyidentification, data=medrr))
app_med1_medrrm3 = (lm(w2.article_feel_5 ~ as.factor(condition3) + gender + racialresentment + ideology + education + income + age + partyidentification, data=medrr))
texreg(list(app_med1_medrrm1, app_med1_medrrm2, app_med1_medrrm3), stars = c(0.1, 0.05, 0.01))

# Table C65
app_med1medrrm_effect = app_med_medrr1$coefficients[3]*app_med1_medrrm1$coefficients[2] + 
  app_med_medrr1$coefficients[4]*app_med1_medrrm2$coefficients[2] + 
  app_med_medrr1$coefficients[5]*app_med1_medrrm3$coefficients[2]
app_med2medrrm_effect = app_med_medrr2$coefficients[3]*app_med1_medrrm1$coefficients[2] + 
  app_med_medrr2$coefficients[4]*app_med1_medrrm2$coefficients[2] + 
  app_med_medrr2$coefficients[5]*app_med1_medrrm3$coefficients[2]
app_med3medrrm_effect = app_med_medrr3$coefficients[3]*app_med1_medrrm1$coefficients[2] + 
  app_med_medrr3$coefficients[4]*app_med1_medrrm2$coefficients[2] + 
  app_med_medrr3$coefficients[5]*app_med1_medrrm3$coefficients[2]
app_med4medrrm_effect = app_med_medrr4$coefficients[3]*app_med1_medrrm1$coefficients[2] + 
  app_med_medrr4$coefficients[4]*app_med1_medrrm2$coefficients[2] + 
  app_med_medrr4$coefficients[5]*app_med1_medrrm3$coefficients[2]
app_med5medrrm_effect = app_med_medrr5$coefficients[3]*app_med1_medrrm1$coefficients[2] + 
  app_med_medrr5$coefficients[4]*app_med1_medrrm2$coefficients[2] + 
  app_med_medrr5$coefficients[5]*app_med1_medrrm3$coefficients[2]

# Levels of racial resentment: Higher RR
highrr = subset(data_noallay, data_noallay$rr_bin == "Higher RR")

highrr2 <- highrr[,c("w2.article_feel_combo_anxiety3", "condition3", "w2.flyer_agree", "w2.flyer_insens", "w2.flyer_fairpt", "w2.flyer_offend", "w2.flyer_conflict", "w2.flyer_vote", "racialresentment", "gender", "partyidentification", "ideology", "education", "income", "age")]
highrr2 <- highrr2[complete.cases(highrr2), ]

model_med = lm(w2.article_feel_combo_anxiety3 ~ condition3 + gender + racialresentment + ideology + education + income + age + partyidentification, data = highrr2)

set.seed(235)
# fair point
model_out_fairpt = lm(w2.flyer_fairpt ~ condition3 * w2.article_feel_combo_anxiety3 + gender + racialresentment + ideology + education + income + age + partyidentification, data=highrr2)
model_combo_fairpt = mediation::mediate(model_med, model_out_fairpt, treat="condition3", mediator="w2.article_feel_combo_anxiety3", sims=1000)
summary(model_combo_fairpt)

# vote
model_out_vote = lm(w2.flyer_vote ~ condition3 * w2.article_feel_combo_anxiety3 + gender + racialresentment + ideology + education + income + age + partyidentification, data=highrr2)
model_combo_vote = mediation::mediate(model_med, model_out_vote, treat="condition3", mediator="w2.article_feel_combo_anxiety3", sims=1000)
summary(model_combo_vote)

# offend
model_out_offend = lm(w2.flyer_offend ~ condition3 * w2.article_feel_combo_anxiety3 + gender + racialresentment + partyidentification + ideology + education + income + age, data=highrr2)
model_combo_offend = mediation::mediate(model_med, model_out_offend, treat="condition3", mediator="w2.article_feel_combo_anxiety3", sims=1000)
summary(model_combo_offend)

# insensitive
model_out_insens = lm(w2.flyer_insens ~ condition3 * w2.article_feel_combo_anxiety3 + gender + racialresentment + partyidentification + ideology + education + income + age, data=highrr2)
model_combo_insens = mediation::mediate(model_med, model_out_insens, treat="condition3", mediator="w2.article_feel_combo_anxiety3", sims=1000)
summary(model_combo_insens)

# agree
model_out_agree = lm(w2.flyer_agree ~ condition3 * w2.article_feel_combo_anxiety3 + gender + racialresentment + partyidentification + ideology + education + income + age, data=highrr2)
model_combo_agree = mediation::mediate(model_med, model_out_agree, treat="condition3", mediator="w2.article_feel_combo_anxiety3", sims=1000)
summary(model_combo_agree)

# Table C71
app_med_highrr1 = (lm(w2.flyer_fairpt ~ as.factor(condition3) + w2.article_feel_1 + w2.article_feel_3 + w2.article_feel_5 + gender + racialresentment + ideology + education + income + age + partyidentification, data=highrr))
app_med_highrr2 = (lm(w2.flyer_vote ~ as.factor(condition3) + w2.article_feel_1 + w2.article_feel_3 + w2.article_feel_5 + gender + racialresentment + ideology + education + income + age + partyidentification, data=highrr))
app_med_highrr3 = (lm(w2.flyer_offend ~ as.factor(condition3) + w2.article_feel_1 + w2.article_feel_3 + w2.article_feel_5 + gender + racialresentment + ideology + education + income + age + partyidentification, data=highrr))
app_med_highrr4 = (lm(w2.flyer_insens ~ as.factor(condition3) + w2.article_feel_1 + w2.article_feel_3 + w2.article_feel_5 + gender + racialresentment + ideology + education + income + age + partyidentification, data=highrr))
app_med_highrr5 = (lm(w2.flyer_agree ~ as.factor(condition3) + w2.article_feel_1 + w2.article_feel_3 + w2.article_feel_5 + gender + racialresentment + ideology + education + income + age + partyidentification, data=highrr))
texreg(list(app_med_highrr1, app_med_highrr2, app_med_highrr3, app_med_highrr4, app_med_highrr5), stars=c(0.1, 0.05, 0.01))

# Table C72
app_med1_highrrm1 = (lm(w2.article_feel_1 ~ as.factor(condition3) + gender + racialresentment + ideology + education + income + age + partyidentification, data=highrr))
app_med1_highrrm2 = (lm(w2.article_feel_3 ~ as.factor(condition3) + gender + racialresentment + ideology + education + income + age + partyidentification, data=highrr))
app_med1_highrrm3 = (lm(w2.article_feel_5 ~ as.factor(condition3) + gender + racialresentment + ideology + education + income + age + partyidentification, data=highrr))
texreg(list(app_med1_highrrm1, app_med1_highrrm2, app_med1_highrrm3), stars = c(0.1, 0.05, 0.01))

# Table C73
app_med1highrrm_effect = app_med_highrr1$coefficients[3]*app_med1_highrrm1$coefficients[2] + 
  app_med_highrr1$coefficients[4]*app_med1_highrrm2$coefficients[2] + 
  app_med_highrr1$coefficients[5]*app_med1_highrrm3$coefficients[2]
app_med2highrrm_effect = app_med_highrr2$coefficients[3]*app_med1_highrrm1$coefficients[2] + 
  app_med_highrr2$coefficients[4]*app_med1_highrrm2$coefficients[2] + 
  app_med_highrr2$coefficients[5]*app_med1_highrrm3$coefficients[2]
app_med3highrrm_effect = app_med_highrr3$coefficients[3]*app_med1_highrrm1$coefficients[2] + 
  app_med_highrr3$coefficients[4]*app_med1_highrrm2$coefficients[2] + 
  app_med_highrr3$coefficients[5]*app_med1_highrrm3$coefficients[2]
app_med4highrrm_effect = app_med_highrr4$coefficients[3]*app_med1_highrrm1$coefficients[2] + 
  app_med_highrr4$coefficients[4]*app_med1_highrrm2$coefficients[2] + 
  app_med_highrr4$coefficients[5]*app_med1_highrrm3$coefficients[2]
app_med5highrrm_effect = app_med_highrr5$coefficients[3]*app_med1_highrrm1$coefficients[2] + 
  app_med_highrr5$coefficients[4]*app_med1_highrrm2$coefficients[2] + 
  app_med_highrr5$coefficients[5]*app_med1_highrrm3$coefficients[2]

######
######### Appendix D: Additional Mediation Models
######

# Status allay (treatment) compared to status threat (control)
data_nocontrol$condition3 = ifelse(data_nocontrol$condition=="ST_Treatment1", 0,
                                   ifelse(data_nocontrol$condition=="SA_Treatment2", 1, NA))

data_nocontrol2 <- data_nocontrol
data_nocontrol2 <- data_nocontrol2[,c("w2.article_feel_combo_anxiety3", "condition3", "w2.flyer_agree", "w2.flyer_insens", "w2.flyer_fairpt", "w2.flyer_offend", "w2.flyer_conflict", "w2.flyer_vote", "racialresentment", "gender", "partyidentification", "ideology", "education", "income", "age")]
data_nocontrol2 <- data_nocontrol2[complete.cases(data_nocontrol2), ]

data_nocontrol2$condition3 <- as.factor(data_nocontrol2$condition3)

model_med = lm(w2.article_feel_combo_anxiety3 ~ condition3 + gender + racialresentment + ideology + education + income + age + partyidentification, data = data_nocontrol2)

set.seed(235)
# Table D1
model_out_fairpt = lm(w2.flyer_fairpt ~ condition3 * w2.article_feel_combo_anxiety3 + gender + racialresentment + ideology + education + income + age + partyidentification, data=data_nocontrol2)
model_combo_fairpt = mediation::mediate(model_med, model_out_fairpt, treat="condition3", mediator="w2.article_feel_combo_anxiety3", sims=1000)
summary(model_combo_fairpt)

# Table D2
model_out_vote = lm(w2.flyer_vote ~ condition3 * w2.article_feel_combo_anxiety3 + gender + racialresentment + ideology + education + income + age + partyidentification, data=data_nocontrol2)
model_combo_vote = mediation::mediate(model_med, model_out_vote, treat="condition3", mediator="w2.article_feel_combo_anxiety3", sims=1000)
summary(model_combo_vote)

# Table D3
model_out_offend = lm(w2.flyer_offend ~ condition3 * w2.article_feel_combo_anxiety3 + gender + racialresentment + partyidentification + ideology + education + income + age, data=data_nocontrol2)
model_combo_offend = mediation::mediate(model_med, model_out_offend, treat="condition3", mediator="w2.article_feel_combo_anxiety3", sims=1000)
summary(model_combo_offend)

# Table D4
model_out_insens = lm(w2.flyer_insens ~ condition3 * w2.article_feel_combo_anxiety3 + gender + racialresentment + partyidentification + ideology + education + income + age, data=data_nocontrol2)
model_combo_insens = mediation::mediate(model_med, model_out_insens, treat="condition3", mediator="w2.article_feel_combo_anxiety3", sims=1000)
summary(model_combo_insens)

# Table D5
model_out_agree = lm(w2.flyer_agree ~ condition3 * w2.article_feel_combo_anxiety3 + gender + racialresentment + partyidentification + ideology + education + income + age, data=data_nocontrol2)
model_combo_agree = mediation::mediate(model_med, model_out_agree, treat="condition3", mediator="w2.article_feel_combo_anxiety3", sims=1000)
summary(model_combo_agree)

# Status allay (treatment) compared to true control
data_nothreat$condition3 = ifelse(data_nothreat$condition=="Control", 0,
                                  ifelse(data_nothreat$condition=="SA_Treatment2", 1, NA))

data_nothreat2 <- data_nothreat
data_nothreat2 <- data_nothreat2[,c("w2.article_feel_combo_anxiety3", "condition3", "w2.flyer_agree", "w2.flyer_insens", "w2.flyer_fairpt", "w2.flyer_offend", "w2.flyer_conflict", "w2.flyer_vote", "racialresentment", "gender", "partyidentification", "ideology", "education", "income", "age")]
data_nothreat2 <- data_nothreat2[complete.cases(data_nothreat2), ]

data_nothreat2$condition3 <- as.factor(data_nothreat2$condition3)

model_med = lm(w2.article_feel_combo_anxiety3 ~ condition3 + gender + racialresentment + ideology + education + income + age + partyidentification, data = data_nothreat2)

set.seed(235)
# Table D6
model_out_fairpt = lm(w2.flyer_fairpt ~ condition3 * w2.article_feel_combo_anxiety3 + gender + racialresentment + ideology + education + income + age + partyidentification, data=data_nothreat2)
model_combo_fairpt = mediation::mediate(model_med, model_out_fairpt, treat="condition3", mediator="w2.article_feel_combo_anxiety3", sims=1000)
summary(model_combo_fairpt)

# Table D7
model_out_vote = lm(w2.flyer_vote ~ condition3 * w2.article_feel_combo_anxiety3 + gender + racialresentment + ideology + education + income + age + partyidentification, data=data_nothreat2)
model_combo_vote = mediation::mediate(model_med, model_out_vote, treat="condition3", mediator="w2.article_feel_combo_anxiety3", sims=1000)
summary(model_combo_vote)

# Table D8
model_out_offend = lm(w2.flyer_offend ~ condition3 * w2.article_feel_combo_anxiety3 + gender + racialresentment + partyidentification + ideology + education + income + age, data=data_nothreat2)
model_combo_offend = mediation::mediate(model_med, model_out_offend, treat="condition3", mediator="w2.article_feel_combo_anxiety3", sims=1000)
summary(model_combo_offend)

# Table D9
model_out_insens = lm(w2.flyer_insens ~ condition3 * w2.article_feel_combo_anxiety3 + gender + racialresentment + partyidentification + ideology + education + income + age, data=data_nothreat2)
model_combo_insens = mediation::mediate(model_med, model_out_insens, treat="condition3", mediator="w2.article_feel_combo_anxiety3", sims=1000)
summary(model_combo_insens)

# Table D10 
model_out_agree = lm(w2.flyer_agree ~ condition3 * w2.article_feel_combo_anxiety3 + gender + racialresentment + partyidentification + ideology + education + income + age, data=data_nothreat2)
model_combo_agree = mediation::mediate(model_med, model_out_agree, treat="condition3", mediator="w2.article_feel_combo_anxiety3", sims=1000)
summary(model_combo_agree)

######
######### Appendix E: Student Sample
######

rm(list=ls())
load("/Users/leahchristiani/Dropbox/Papers/2021_PB_ExplicitAppeals/Final_Documents/Appendix_Datasets/GT_Data_Merged_March2019.RData")

# Note: Contact author for supplemental data 

# Figure E1
pdf("racatt_dist_students.pdf", width=7, height=4)
par(mfrow=c(1,2))
hist(data$racialresentment, main="", xlab="Racial Resentment")
hist(data$fire, main="", xlab="Fire")
dev.off()

# Table E1 
mins <- cbind(min(data$w2.flyer_fairpt, na.rm=T), min(data$w2.flyer_insens, na.rm=T), 
min(data$w2.flyer_agree, na.rm=T), min(data$w2.flyer_offend, na.rm=T), 
min(data$w2.flyer_vote, na.rm=T), min(data$w2.article_feel_combo_anxiety, na.rm=T))
maxs <- cbind(max(data$w2.flyer_fairpt, na.rm=T), max(data$w2.flyer_insens, na.rm=T), 
              max(data$w2.flyer_agree, na.rm=T), max(data$w2.flyer_offend, na.rm=T), 
              max(data$w2.flyer_vote, na.rm=T), max(data$w2.article_feel_combo_anxiety, na.rm=T))
means <- cbind(mean(data$w2.flyer_fairpt, na.rm=T), mean(data$w2.flyer_insens, na.rm=T), 
               mean(data$w2.flyer_agree, na.rm=T), mean(data$w2.flyer_offend, na.rm=T), 
               mean(data$w2.flyer_vote, na.rm=T), mean(data$w2.article_feel_combo_anxiety, na.rm=T))
sds <- cbind(sd(data$w2.flyer_fairpt, na.rm=T), sd(data$w2.flyer_insens, na.rm=T), 
             sd(data$w2.flyer_agree, na.rm=T), sd(data$w2.flyer_offend, na.rm=T), 
             sd(data$w2.flyer_vote, na.rm=T), sd(data$w2.article_feel_combo_anxiety, na.rm=T))
ns <- cbind(sum(!is.na(data$w2.flyer_fairpt)), sum(!is.na(data$w2.flyer_insens)), 
            sum(!is.na(data$w2.flyer_agree)), sum(!is.na(data$w2.flyer_offend)), 
            sum(!is.na(data$w2.flyer_vote)), sum(!is.na(data$w2.article_feel_combo_anxiety)))
names <- c("N", "Mean", "SD", "Min", "Max")

tab <- xtable(t(rbind(ns, means, sds, mins, maxs)))
names(tab) <- names
rownames(tab) <- c("Flyer: Fair point", "Flyer: Insensitive", "Flyer: Agree","Flyer: Offend", "Flyer: Vote", "Article: Negative Emotions Scale")
tab

# Table E2
manip <- lm(w2.article_stthreat ~ as.factor(condition) + stthreat, data=data)
texreg(list(manip), digits=2, stars = c(0.05, 0.01))

# Table E3
data$condition_name = ifelse(data$condition=="Control", "Control",
                             ifelse(data$condition=="SA_Treatment2", "Status Allay",
                                    ifelse(data$condition=="ST_Treatment1", "Status Threat", NA)))
fairpt1 = lm(w2.flyer_fairpt ~ as.factor(condition_name), data=data)
vote1 = lm(w2.flyer_vote ~ as.factor(condition_name), data=data)
offend1 = lm(w2.flyer_offend ~ as.factor(condition_name), data=data)
insens1 = lm(w2.flyer_insens ~ as.factor(condition_name), data=data)
agree1 = lm(w2.flyer_agree ~ as.factor(condition_name), data=data)
texreg(list(fairpt1, vote1, offend1, insens1, agree1), digits=2, stars=c(0.05))

######
######### Appendix F: Pre-Registration
######


######
######### Appendix G: ANES Analysis
######

rm(list=ls())

# Note: Use 2016 ANES data

# main DV (higher values mean people are too easily offended)
anes$polcorrect = ifelse(anes$V161362<1,NA,anes$V161362)

# main IV (higher values mean whites have too little influence)
anes$whiteinfluence = ifelse(anes$V162322<1,NA,anes$V162322)

# control variables
anes$gender = ifelse(anes$V161342 == 1, "male", 
                     ifelse(anes$V161342 == 2, "female", NA))
anes$white = ifelse(anes$V161310x == 1, 1,
                    ifelse(anes$V161310x == -2, NA, 0))
anes$ideology = ifelse(anes$V162171<1 | anes$V162171>7, NA, anes$V162171)
anes$partyid = ifelse(anes$V161158x<1, NA, anes$V161158x)
anes$education = ifelse(anes$V161270<1 | anes$V161270 >16, NA, anes$V161270)
anes$age = ifelse(anes$V161267<18, NA, anes$V161267)
anes$relig = ifelse(anes$V161265x<1, NA, anes$V161265x)
anes$income = ifelse(anes$V161361x<1, NA, anes$V161361x)
anes$rr1 = recode(anes$V162211, '1=5; 2=4; 3=3; 4=2; 5=1; -9=NA; -8=NA; -7=NA; -6=NA', as.numeric=T)
anes$rr2 = ifelse(anes$V162212<1, NA, anes$V162212)
anes$rr3 = ifelse(anes$V162213<1, NA, anes$V162213)
anes$rr4 = recode(anes$V162214, '1=5; 2=4; 3=3; 4=2; 5=1; -9=NA; -8=NA; -7=NA; -6=NA', as.numeric=T)
anes$whiteid = recode(anes$V162327, '1=5; 2=4; 3=3; 4=2; 5=1; -9=NA; -7=NA; -6=NA; -5=NA; -1=NA', as.numeric=T)
anes$racialresentment = (anes$rr1 + anes$rr2 + anes$rr3 + anes$rr4)
anes$racialresentment = (anes$racialresentment - min(anes$racialresentment, na.rm=T))/(max(anes$racialresentment, na.rm=T) - min(anes$racialresentment, na.rm=T))

# Bivariate model
mod1 = (lm(polcorrect ~ as.factor(whiteinfluence), data=subset(anes, anes$white==1), weights = V160102))

# Model with controls 
mod2 = (lm(polcorrect ~ as.factor(whiteinfluence) + gender + ideology + partyid + education + racialresentment + age + as.factor(relig) + income + whiteid, data=subset(anes, anes$white==1), weights = V160102))

# Table G1
texreg(list(mod1, mod2), digits=2)

######
######### Appendix H: Survey 2 in Summer 2019
######

# Note: Contact author for supplemental data (UNC IRB #19-1253)

rm(list=ls(all=TRUE))

threat$condition_name = ifelse(threat$condition==1, "Control",
                               ifelse(threat$condition==2, "Cultural Threat",
                                      ifelse(threat$condition==3, "Economic Threat", NA)))

threat$article_feel_combo_anxiety3 = (threat$article_feel_1 + threat$article_feel_3 + threat$article_feel_5)/3

# Table H1: Descriptive statistics 
mins <- cbind(min(threat$fairpt, na.rm=T),
              min(threat$vote, na.rm=T),
              min(threat$agree1, na.rm=T),
              min(threat$agree2, na.rm=T),
              min(threat$agree3, na.rm=T),
              min(threat$reparations, na.rm=T),
              
              min(threat$article_feel_1, na.rm=T),
              min(threat$article_feel_2, na.rm=T),
              min(threat$article_feel_3, na.rm=T),
              min(threat$article_feel_4, na.rm=T),
              min(threat$article_feel_5, na.rm=T),
              min(threat$article_feel_6, na.rm=T),
              min(threat$article_feel_combo_anxiety3, na.rm=T),
              
              min(threat$racialresentment, na.rm=T),
              min(threat$partyidentification, na.rm=T),
              min(threat$ideology, na.rm=T),
              min(threat$educ, na.rm=T),
              min(threat$age, na.rm=T),
              min(threat$income, na.rm=T))
maxs <- cbind(max(threat$fairpt, na.rm=T),
              max(threat$vote, na.rm=T),
              max(threat$agree1, na.rm=T),
              max(threat$agree2, na.rm=T),
              max(threat$agree3, na.rm=T),
              max(threat$reparations, na.rm=T),
              
              max(threat$article_feel_1, na.rm=T),
              max(threat$article_feel_2, na.rm=T),
              max(threat$article_feel_3, na.rm=T),
              max(threat$article_feel_4, na.rm=T),
              max(threat$article_feel_5, na.rm=T),
              max(threat$article_feel_6, na.rm=T),
              max(threat$article_feel_combo_anxiety3, na.rm=T),
              
              max(threat$racialresentment, na.rm=T),
              max(threat$partyidentification, na.rm=T),
              max(threat$ideology, na.rm=T),
              max(threat$educ, na.rm=T),
              max(threat$age, na.rm=T),
              max(threat$income, na.rm=T))
means <- cbind(mean(threat$fairpt, na.rm=T),
               mean(threat$vote, na.rm=T),
               mean(threat$agree1, na.rm=T),
               mean(threat$agree2, na.rm=T),
               mean(threat$agree3, na.rm=T),
               mean(threat$reparations, na.rm=T),
               
               mean(threat$article_feel_1, na.rm=T),
               mean(threat$article_feel_2, na.rm=T),
               mean(threat$article_feel_3, na.rm=T),
               mean(threat$article_feel_4, na.rm=T),
               mean(threat$article_feel_5, na.rm=T),
               mean(threat$article_feel_6, na.rm=T),
               mean(threat$article_feel_combo_anxiety3, na.rm=T),
               
               mean(threat$racialresentment, na.rm=T),
               mean(threat$partyidentification, na.rm=T),
               mean(threat$ideology, na.rm=T),
               mean(threat$educ, na.rm=T),
               mean(threat$age, na.rm=T),
               mean(threat$income, na.rm=T))
sds <- cbind(sd(threat$fairpt, na.rm=T),
             sd(threat$vote, na.rm=T),
             sd(threat$agree1, na.rm=T),
             sd(threat$agree2, na.rm=T),
             sd(threat$agree3, na.rm=T),
             sd(threat$reparations, na.rm=T),
             
             sd(threat$article_feel_1, na.rm=T),
             sd(threat$article_feel_2, na.rm=T),
             sd(threat$article_feel_3, na.rm=T),
             sd(threat$article_feel_4, na.rm=T),
             sd(threat$article_feel_5, na.rm=T),
             sd(threat$article_feel_6, na.rm=T),
             sd(threat$article_feel_combo_anxiety3, na.rm=T),
             
             sd(threat$racialresentment, na.rm=T),
             
             sd(threat$partyidentification, na.rm=T),
             sd(threat$ideology, na.rm=T),
             sd(threat$educ, na.rm=T),
             sd(threat$age, na.rm=T),
             sd(threat$income, na.rm=T))
ns <- cbind(sum(!is.na(threat$fairpt)),
            sum(!is.na(threat$vote)),
            sum(!is.na(threat$agree1)),
            sum(!is.na(threat$agree2)),
            sum(!is.na(threat$agree3)),
            sum(!is.na(threat$reparations)),
            
            sum(!is.na(threat$article_feel_1)),
            sum(!is.na(threat$article_feel_2)),
            sum(!is.na(threat$article_feel_3)),
            sum(!is.na(threat$article_feel_4)),
            sum(!is.na(threat$article_feel_5)),
            sum(!is.na(threat$article_feel_6)),
            sum(!is.na(threat$article_feel_combo_anxiety3)),
            
            sum(!is.na(threat$racialresentment)),
            
            sum(!is.na(threat$partyidentification)),
            sum(!is.na(threat$ideology)),
            sum(!is.na(threat$educ)),
            sum(!is.na(threat$age)),
            sum(!is.na(threat$income)))
tab <- xtable(t(rbind(ns, means, sds, mins, maxs)))

names <- c("N", "Mean", "SD", "Min", "Max")

names(tab) <- names
rownames(tab) <- c("Fair Point", "Vote", "Agree 1", "Agree 2", "Agree 3", "Reparations", "Anxiety", "Pride", "Anger", "Hope", "Worry","Excitement", "Felt Threat Scale", "Racial Resentment", "Party Identification", "Ideology", "Education", "Age", "Income")
tab
xtable(tab, digits=2)

# Table H2: Balance checks
b1=(lm(partyidentification ~ as.factor(condition_name), data=threat))
b2=(lm(ideology ~ as.factor(condition_name), data=threat))
b3=(lm(racialresentment ~ as.factor(condition_name), data=threat))
b4=(lm(educ ~ as.factor(condition_name), data=threat)) 
b5=(lm(income ~ as.factor(condition_name), data=threat))
b6=(lm(gender ~ as.factor(condition_name), data=threat))
b7=(lm(age ~ as.factor(condition_name), data=threat))
texreg(list(b1,b2,b3,b4,b5,b6,b7), digits=2, stars=c(0.05, 0.01))

# Table H3: Manipulation checks
m3=(lm(manipecon ~ as.factor(condition_name), data=threat))
m2=(lm(manipcult ~ as.factor(condition_name), data=threat))
m1=(lm(manip ~ as.factor(condition_name), data=threat))

texreg(list(m1,m2,m3), digits=2)

# Table H4: Mediation models for cultural threat condition compared to control
# Mediator: Anxiety
threat_noecon = subset(threat, threat$condition!=3)
threat_noecon$condition3 = ifelse(threat_noecon$condition_name == "Control", 0,
                                  ifelse(threat_noecon$condition_name == "Cultural Threat", 1, NA))

threat_noecon2 <- threat_noecon[,c("condition3", "racialresentment", "article_feel_1", "gender", "partyidentification", "ideology", "educ", "income", "age", "fairpt", "vote", "agree1", "agree2", "agree3", "reparations")]

threat_noecon2 <- threat_noecon2[complete.cases(threat_noecon2), ]

threat_noecon2$condition3 = as.factor(threat_noecon2$condition3)
threat_noecon2$gender = as.factor(threat_noecon2$gender)

model_med = lm(article_feel_1 ~ condition3 + gender + racialresentment + partyidentification + ideology + educ + income + age, data = threat_noecon2)

set.seed(2346)
model_out_fairpt = lm(fairpt ~ condition3 * article_feel_1 + gender + racialresentment + partyidentification + ideology + educ + income + age, data=threat_noecon2)
model_combo_fairpt = mediation::mediate(model_med, model_out_fairpt, treat="condition3", mediator="article_feel_1", sims=1000)
summary(model_combo_fairpt)

model_out_vote = lm(vote ~ condition3 * article_feel_1 + gender + racialresentment + partyidentification + ideology + educ + income + age, data=threat_noecon2)
model_combo_vote = mediation::mediate(model_med, model_out_vote, treat="condition3", mediator="article_feel_1", sims=1000)
summary(model_combo_vote)

model_out_agree1 = lm(agree1 ~ condition3 * article_feel_1 + gender + racialresentment + partyidentification + ideology + educ + income + age, data=threat_noecon2)
model_combo_agree1 = mediation::mediate(model_med, model_out_agree1, treat="condition3", mediator="article_feel_1", sims=1000)
summary(model_combo_agree1)

model_out_agree2 = lm(agree2 ~ condition3 * article_feel_1 + gender + racialresentment + partyidentification + ideology + educ + income + age, data=threat_noecon2)
model_combo_agree2 = mediation::mediate(model_med, model_out_agree2, treat="condition3", mediator="article_feel_1", sims=1000)
summary(model_combo_agree2)

model_out_agree3 = lm(agree3 ~ condition3 * article_feel_1 + gender + racialresentment + partyidentification + ideology + educ + income + age, data=threat_noecon2)
model_combo_agree3 = mediation::mediate(model_med, model_out_agree3, treat="condition3", mediator="article_feel_1", sims=1000)
summary(model_combo_agree3)

model_out_rep = lm(reparations ~ condition3 * article_feel_1 + gender + racialresentment + partyidentification + ideology + educ + income + age, data=threat_noecon2)
model_combo_rep = mediation::mediate(model_med, model_out_rep, treat="condition3", mediator="article_feel_1", sims=1000)
summary(model_combo_rep)

# Mediator: Anger
threat_noecon2 <- threat_noecon[,c("condition3", "racialresentment", "article_feel_3", "gender", "partyidentification", "ideology", "educ", "income", "age", "fairpt", "vote", "agree1", "agree2", "agree3", "reparations")]

threat_noecon2 <- threat_noecon2[complete.cases(threat_noecon2), ]

threat_noecon2$condition3 = as.factor(threat_noecon2$condition3)
threat_noecon2$gender = as.factor(threat_noecon2$gender)

model_med = lm(article_feel_3 ~ condition3 + gender + racialresentment + partyidentification + ideology + educ + income + age, data = threat_noecon2)

set.seed(2346)
model_out_fairpt = lm(fairpt ~ condition3 * article_feel_3 + gender + racialresentment + partyidentification + ideology + educ + income + age, data=threat_noecon2)
model_combo_fairpt = mediation::mediate(model_med, model_out_fairpt, treat="condition3", mediator="article_feel_3", sims=1000)
summary(model_combo_fairpt)

model_out_vote = lm(vote ~ condition3 * article_feel_3 + gender + racialresentment + partyidentification + ideology + educ + income + age, data=threat_noecon2)
model_combo_vote = mediation::mediate(model_med, model_out_vote, treat="condition3", mediator="article_feel_3", sims=1000)
summary(model_combo_vote)

model_out_agree1 = lm(agree1 ~ condition3 * article_feel_3 + gender + racialresentment + partyidentification + ideology + educ + income + age, data=threat_noecon2)
model_combo_agree1 = mediation::mediate(model_med, model_out_agree1, treat="condition3", mediator="article_feel_3", sims=1000)
summary(model_combo_agree1)

model_out_agree2 = lm(agree2 ~ condition3 * article_feel_3 + gender + racialresentment + partyidentification + ideology + educ + income + age, data=threat_noecon2)
model_combo_agree2 = mediation::mediate(model_med, model_out_agree2, treat="condition3", mediator="article_feel_3", sims=1000)
summary(model_combo_agree2)

model_out_agree3 = lm(agree3 ~ condition3 * article_feel_3 + gender + racialresentment + partyidentification + ideology + educ + income + age, data=threat_noecon2)
model_combo_agree3 = mediation::mediate(model_med, model_out_agree3, treat="condition3", mediator="article_feel_3", sims=1000)
summary(model_combo_agree3)

model_out_rep = lm(reparations ~ condition3 * article_feel_3 + gender + racialresentment + partyidentification + ideology + educ + income + age, data=threat_noecon2)
model_combo_rep = mediation::mediate(model_med, model_out_rep, treat="condition3", mediator="article_feel_3", sims=1000)
summary(model_combo_rep)

# Mediator: Worry
threat_noecon2 <- threat_noecon[,c("condition3", "racialresentment", "article_feel_5", "gender", "partyidentification", "ideology", "educ", "income", "age", "fairpt", "vote", "agree1", "agree2", "agree3", "reparations")]

threat_noecon2 <- threat_noecon2[complete.cases(threat_noecon2), ]

threat_noecon2$condition3 = as.factor(threat_noecon2$condition3)
threat_noecon2$gender = as.factor(threat_noecon2$gender)

model_med = lm(article_feel_5 ~ condition3 + gender + racialresentment + partyidentification + ideology + educ + income + age, data = threat_noecon2)

set.seed(2346)
model_out_fairpt = lm(fairpt ~ condition3 * article_feel_5 + gender + racialresentment + partyidentification + ideology + educ + income + age, data=threat_noecon2)
model_combo_fairpt = mediation::mediate(model_med, model_out_fairpt, treat="condition3", mediator="article_feel_5", sims=1000)
summary(model_combo_fairpt)

model_out_vote = lm(vote ~ condition3 * article_feel_5 + gender + racialresentment + partyidentification + ideology + educ + income + age, data=threat_noecon2)
model_combo_vote = mediation::mediate(model_med, model_out_vote, treat="condition3", mediator="article_feel_5", sims=1000)
summary(model_combo_vote)

model_out_agree1 = lm(agree1 ~ condition3 * article_feel_5 + gender + racialresentment + partyidentification + ideology + educ + income + age, data=threat_noecon2)
model_combo_agree1 = mediation::mediate(model_med, model_out_agree1, treat="condition3", mediator="article_feel_5", sims=1000)
summary(model_combo_agree1)

model_out_agree2 = lm(agree2 ~ condition3 * article_feel_5 + gender + racialresentment + partyidentification + ideology + educ + income + age, data=threat_noecon2)
model_combo_agree2 = mediation::mediate(model_med, model_out_agree2, treat="condition3", mediator="article_feel_5", sims=1000)
summary(model_combo_agree2)

model_out_agree3 = lm(agree3 ~ condition3 * article_feel_5 + gender + racialresentment + partyidentification + ideology + educ + income + age, data=threat_noecon2)
model_combo_agree3 = mediation::mediate(model_med, model_out_agree3, treat="condition3", mediator="article_feel_5", sims=1000)
summary(model_combo_agree3)

model_out_rep = lm(reparations ~ condition3 * article_feel_5 + gender + racialresentment + partyidentification + ideology + educ + income + age, data=threat_noecon2)
model_combo_rep = mediation::mediate(model_med, model_out_rep, treat="condition3", mediator="article_feel_5", sims=1000)
summary(model_combo_rep)

# Mediator: Felt threat scale 
threat_noecon2 <- threat_noecon[,c("condition3", "racialresentment", "article_feel_combo_anxiety3", "gender", "partyidentification", "ideology", "educ", "income", "age", "fairpt", "vote", "agree1", "agree2", "agree3", "reparations")]

threat_noecon2 <- threat_noecon2[complete.cases(threat_noecon2), ]

threat_noecon2$condition3 = as.factor(threat_noecon2$condition3)
threat_noecon2$gender = as.factor(threat_noecon2$gender)

model_med = lm(article_feel_combo_anxiety3 ~ condition3 + gender + racialresentment + partyidentification + ideology + educ + income + age, data = threat_noecon2)

set.seed(2346)
model_out_fairpt = lm(fairpt ~ condition3 * article_feel_combo_anxiety3 + gender + racialresentment + partyidentification + ideology + educ + income + age, data=threat_noecon2)
model_combo_fairpt = mediation::mediate(model_med, model_out_fairpt, treat="condition3", mediator="article_feel_combo_anxiety3", sims=1000)
summary(model_combo_fairpt)

model_out_vote = lm(vote ~ condition3 * article_feel_combo_anxiety3 + gender + racialresentment + partyidentification + ideology + educ + income + age, data=threat_noecon2)
model_combo_vote = mediation::mediate(model_med, model_out_vote, treat="condition3", mediator="article_feel_combo_anxiety3", sims=1000)
summary(model_combo_vote)

model_out_agree1 = lm(agree1 ~ condition3 * article_feel_combo_anxiety3 + gender + racialresentment + partyidentification + ideology + educ + income + age, data=threat_noecon2)
model_combo_agree1 = mediation::mediate(model_med, model_out_agree1, treat="condition3", mediator="article_feel_combo_anxiety3", sims=1000)
summary(model_combo_agree1)

model_out_agree2 = lm(agree2 ~ condition3 * article_feel_combo_anxiety3 + gender + racialresentment + partyidentification + ideology + educ + income + age, data=threat_noecon2)
model_combo_agree2 = mediation::mediate(model_med, model_out_agree2, treat="condition3", mediator="article_feel_combo_anxiety3", sims=1000)
summary(model_combo_agree2)

model_out_agree3 = lm(agree3 ~ condition3 * article_feel_combo_anxiety3 + gender + racialresentment + partyidentification + ideology + educ + income + age, data=threat_noecon2)
model_combo_agree3 = mediation::mediate(model_med, model_out_agree3, treat="condition3", mediator="article_feel_combo_anxiety3", sims=1000)
summary(model_combo_agree3)

model_out_rep = lm(reparations ~ condition3 * article_feel_combo_anxiety3 + gender + racialresentment + partyidentification + ideology + educ + income + age, data=threat_noecon2)
model_combo_rep = mediation::mediate(model_med, model_out_rep, treat="condition3", mediator="article_feel_combo_anxiety3", sims=1000)
summary(model_combo_rep)

# Mediator: Pride
threat_noecon2 <- threat_noecon[,c("condition3", "racialresentment", "article_feel_2", "gender", "partyidentification", "ideology", "educ", "income", "age", "fairpt", "vote", "agree1", "agree2", "agree3", "reparations")]

threat_noecon2 <- threat_noecon2[complete.cases(threat_noecon2), ]

threat_noecon2$condition3 = as.factor(threat_noecon2$condition3)
threat_noecon2$gender = as.factor(threat_noecon2$gender)

model_med = lm(article_feel_2 ~ condition3 + gender + racialresentment + partyidentification + ideology + educ + income + age, data = threat_noecon2)

set.seed(2346)

model_out_fairpt = lm(fairpt ~ condition3 * article_feel_2 + gender + racialresentment + partyidentification + ideology + educ + income + age, data=threat_noecon2)
model_combo_fairpt = mediation::mediate(model_med, model_out_fairpt, treat="condition3", mediator="article_feel_2", sims=1000)
summary(model_combo_fairpt)

model_out_vote = lm(vote ~ condition3 * article_feel_2 + gender + racialresentment + partyidentification + ideology + educ + income + age, data=threat_noecon2)
model_combo_vote = mediation::mediate(model_med, model_out_vote, treat="condition3", mediator="article_feel_2", sims=1000)
summary(model_combo_vote)

model_out_agree1 = lm(agree1 ~ condition3 * article_feel_2 + gender + racialresentment + partyidentification + ideology + educ + income + age, data=threat_noecon2)
model_combo_agree1 = mediation::mediate(model_med, model_out_agree1, treat="condition3", mediator="article_feel_2", sims=1000)
summary(model_combo_agree1)

model_out_agree2 = lm(agree2 ~ condition3 * article_feel_2 + gender + racialresentment + partyidentification + ideology + educ + income + age, data=threat_noecon2)
model_combo_agree2 = mediation::mediate(model_med, model_out_agree2, treat="condition3", mediator="article_feel_2", sims=1000)
summary(model_combo_agree2)

model_out_agree3 = lm(agree3 ~ condition3 * article_feel_2 + gender + racialresentment + partyidentification + ideology + educ + income + age, data=threat_noecon2)
model_combo_agree3 = mediation::mediate(model_med, model_out_agree3, treat="condition3", mediator="article_feel_2", sims=1000)
summary(model_combo_agree3)

model_out_rep = lm(reparations ~ condition3 * article_feel_2 + gender + racialresentment + partyidentification + ideology + educ + income + age, data=threat_noecon2)
model_combo_rep = mediation::mediate(model_med, model_out_rep, treat="condition3", mediator="article_feel_2", sims=1000)
summary(model_combo_rep)

# Mediator: Hope 
threat_noecon2 <- threat_noecon[,c("condition3", "racialresentment", "article_feel_4", "gender", "partyidentification", "ideology", "educ", "income", "age", "fairpt", "vote", "agree1", "agree2", "agree3", "reparations")]

threat_noecon2 <- threat_noecon2[complete.cases(threat_noecon2), ]

threat_noecon2$condition3 = as.factor(threat_noecon2$condition3)
threat_noecon2$gender = as.factor(threat_noecon2$gender)

model_med = lm(article_feel_4 ~ condition3 + gender + racialresentment + partyidentification + ideology + educ + income + age, data = threat_noecon2)

set.seed(2346)

model_out_fairpt = lm(fairpt ~ condition3 * article_feel_4 + gender + racialresentment + partyidentification + ideology + educ + income + age, data=threat_noecon2)
model_combo_fairpt = mediation::mediate(model_med, model_out_fairpt, treat="condition3", mediator="article_feel_4", sims=1000)
summary(model_combo_fairpt)

model_out_vote = lm(vote ~ condition3 * article_feel_4 + gender + racialresentment + partyidentification + ideology + educ + income + age, data=threat_noecon2)
model_combo_vote = mediation::mediate(model_med, model_out_vote, treat="condition3", mediator="article_feel_4", sims=1000)
summary(model_combo_vote)

model_out_agree1 = lm(agree1 ~ condition3 * article_feel_4 + gender + racialresentment + partyidentification + ideology + educ + income + age, data=threat_noecon2)
model_combo_agree1 = mediation::mediate(model_med, model_out_agree1, treat="condition3", mediator="article_feel_4", sims=1000)
summary(model_combo_agree1)

model_out_agree2 = lm(agree2 ~ condition3 * article_feel_4 + gender + racialresentment + partyidentification + ideology + educ + income + age, data=threat_noecon2)
model_combo_agree2 = mediation::mediate(model_med, model_out_agree2, treat="condition3", mediator="article_feel_4", sims=1000)
summary(model_combo_agree2)

model_out_agree3 = lm(agree3 ~ condition3 * article_feel_4 + gender + racialresentment + partyidentification + ideology + educ + income + age, data=threat_noecon2)
model_combo_agree3 = mediation::mediate(model_med, model_out_agree3, treat="condition3", mediator="article_feel_4", sims=1000)
summary(model_combo_agree3)

model_out_rep = lm(reparations ~ condition3 * article_feel_4 + gender + racialresentment + partyidentification + ideology + educ + income + age, data=threat_noecon2)
model_combo_rep = mediation::mediate(model_med, model_out_rep, treat="condition3", mediator="article_feel_4", sims=1000)
summary(model_combo_rep)

# Mediator: Excitement
threat_noecon2 <- threat_noecon[,c("condition3", "racialresentment", "article_feel_6", "gender", "partyidentification", "ideology", "educ", "income", "age", "fairpt", "vote", "agree1", "agree2", "agree3", "reparations")]

threat_noecon2 <- threat_noecon2[complete.cases(threat_noecon2), ]

threat_noecon2$condition3 = as.factor(threat_noecon2$condition3)
threat_noecon2$gender = as.factor(threat_noecon2$gender)

model_med = lm(article_feel_6 ~ condition3 + gender + racialresentment + partyidentification + ideology + educ + income + age, data = threat_noecon2)

set.seed(2346)

model_out_fairpt = lm(fairpt ~ condition3 * article_feel_6 + gender + racialresentment + partyidentification + ideology + educ + income + age, data=threat_noecon2)
model_combo_fairpt = mediation::mediate(model_med, model_out_fairpt, treat="condition3", mediator="article_feel_6", sims=1000)
summary(model_combo_fairpt)

model_out_vote = lm(vote ~ condition3 * article_feel_6 + gender + racialresentment + partyidentification + ideology + educ + income + age, data=threat_noecon2)
model_combo_vote = mediation::mediate(model_med, model_out_vote, treat="condition3", mediator="article_feel_6", sims=1000)
summary(model_combo_vote)

model_out_agree1 = lm(agree1 ~ condition3 * article_feel_6 + gender + racialresentment + partyidentification + ideology + educ + income + age, data=threat_noecon2)
model_combo_agree1 = mediation::mediate(model_med, model_out_agree1, treat="condition3", mediator="article_feel_6", sims=1000)
summary(model_combo_agree1)

model_out_agree2 = lm(agree2 ~ condition3 * article_feel_6 + gender + racialresentment + partyidentification + ideology + educ + income + age, data=threat_noecon2)
model_combo_agree2 = mediation::mediate(model_med, model_out_agree2, treat="condition3", mediator="article_feel_6", sims=1000)
summary(model_combo_agree2)

model_out_agree3 = lm(agree3 ~ condition3 * article_feel_6 + gender + racialresentment + partyidentification + ideology + educ + income + age, data=threat_noecon2)
model_combo_agree3 = mediation::mediate(model_med, model_out_agree3, treat="condition3", mediator="article_feel_6", sims=1000)
summary(model_combo_agree3)

model_out_rep = lm(reparations ~ condition3 * article_feel_6 + gender + racialresentment + partyidentification + ideology + educ + income + age, data=threat_noecon2)
model_combo_rep = mediation::mediate(model_med, model_out_rep, treat="condition3", mediator="article_feel_6", sims=1000)
summary(model_combo_rep)

# Table H5: Mediation models for economic threat condition compared to control
threat_nocult = subset(threat, threat$condition_name!="Cultural Threat")
threat_nocult$condition3 = ifelse(threat_nocult$condition_name == "Control", 0,
                                  ifelse(threat_nocult$condition_name == "Economic Threat", 1, NA))

# Mediator: Anxiety
threat_nocult2 <- threat_nocult[,c("condition3", "racialresentment", "article_feel_1", "gender", "partyidentification", "ideology", "educ", "income", "age", "fairpt", "vote", "agree1", "agree2", "agree3", "reparations")]

threat_nocult2 <- threat_nocult2[complete.cases(threat_nocult2), ]

threat_nocult2$condition3 = as.factor(threat_nocult2$condition3)
threat_nocult2$gender = as.factor(threat_nocult2$gender)

model_med = lm(article_feel_1 ~ condition3 + gender + racialresentment + partyidentification + ideology + educ + income + age, data = threat_nocult2)

set.seed(2346)
model_out_fairpt = lm(fairpt ~ condition3 * article_feel_1 + gender + racialresentment + partyidentification + ideology + educ + income + age, data=threat_nocult2)
model_combo_fairpt = mediation::mediate(model_med, model_out_fairpt, treat="condition3", mediator="article_feel_1", sims=1000)
summary(model_combo_fairpt)

model_out_vote = lm(vote ~ condition3 * article_feel_1 + gender + racialresentment + partyidentification + ideology + educ + income + age, data=threat_nocult2)
model_combo_vote = mediation::mediate(model_med, model_out_vote, treat="condition3", mediator="article_feel_1", sims=1000)
summary(model_combo_vote)

model_out_agree1 = lm(agree1 ~ condition3 * article_feel_1 + gender + racialresentment + partyidentification + ideology + educ + income + age, data=threat_nocult2)
model_combo_agree1 = mediation::mediate(model_med, model_out_agree1, treat="condition3", mediator="article_feel_1", sims=1000)
summary(model_combo_agree1)

model_out_agree2 = lm(agree2 ~ condition3 * article_feel_1 + gender + racialresentment + partyidentification + ideology + educ + income + age, data=threat_nocult2)
model_combo_agree2 = mediation::mediate(model_med, model_out_agree2, treat="condition3", mediator="article_feel_1", sims=1000)
summary(model_combo_agree2)

model_out_agree3 = lm(agree3 ~ condition3 * article_feel_1 + gender + racialresentment + partyidentification + ideology + educ + income + age, data=threat_nocult2)
model_combo_agree3 = mediation::mediate(model_med, model_out_agree3, treat="condition3", mediator="article_feel_1", sims=1000)
summary(model_combo_agree3)

model_out_rep = lm(reparations ~ condition3 * article_feel_1 + gender + racialresentment + partyidentification + ideology + educ + income + age, data=threat_nocult2)
model_combo_rep = mediation::mediate(model_med, model_out_rep, treat="condition3", mediator="article_feel_1", sims=1000)
summary(model_combo_rep)

# Mediator: Anger
threat_nocult2 <- threat_nocult[,c("condition3", "racialresentment", "article_feel_3", "gender", "partyidentification", "ideology", "educ", "income", "age", "fairpt", "vote", "agree1", "agree2", "agree3", "reparations")]

threat_nocult2 <- threat_nocult2[complete.cases(threat_nocult2), ]

threat_nocult2$condition3 = as.factor(threat_nocult2$condition3)
threat_nocult2$gender = as.factor(threat_nocult2$gender)

model_med = lm(article_feel_3 ~ condition3 + gender + racialresentment + partyidentification + ideology + educ + income + age, data = threat_nocult2)

set.seed(2346)
model_out_fairpt = lm(fairpt ~ condition3 * article_feel_3 + gender + racialresentment + partyidentification + ideology + educ + income + age, data=threat_nocult2)
model_combo_fairpt = mediation::mediate(model_med, model_out_fairpt, treat="condition3", mediator="article_feel_3", sims=1000)
summary(model_combo_fairpt)

model_out_vote = lm(vote ~ condition3 * article_feel_3 + gender + racialresentment + partyidentification + ideology + educ + income + age, data=threat_nocult2)
model_combo_vote = mediation::mediate(model_med, model_out_vote, treat="condition3", mediator="article_feel_3", sims=1000)
summary(model_combo_vote)

model_out_agree1 = lm(agree1 ~ condition3 * article_feel_3 + gender + racialresentment + partyidentification + ideology + educ + income + age, data=threat_nocult2)
model_combo_agree1 = mediation::mediate(model_med, model_out_agree1, treat="condition3", mediator="article_feel_3", sims=1000)
summary(model_combo_agree1)

model_out_agree2 = lm(agree2 ~ condition3 * article_feel_3 + gender + racialresentment + partyidentification + ideology + educ + income + age, data=threat_nocult2)
model_combo_agree2 = mediation::mediate(model_med, model_out_agree2, treat="condition3", mediator="article_feel_3", sims=1000)
summary(model_combo_agree2)

model_out_agree3 = lm(agree3 ~ condition3 * article_feel_3 + gender + racialresentment + partyidentification + ideology + educ + income + age, data=threat_nocult2)
model_combo_agree3 = mediation::mediate(model_med, model_out_agree3, treat="condition3", mediator="article_feel_3", sims=1000)
summary(model_combo_agree3)

model_out_rep = lm(reparations ~ condition3 * article_feel_3 + gender + racialresentment + partyidentification + ideology + educ + income + age, data=threat_nocult2)
model_combo_rep = mediation::mediate(model_med, model_out_rep, treat="condition3", mediator="article_feel_3", sims=1000)
summary(model_combo_rep)

# Mediator: Worry
threat_nocult2 <- threat_nocult[,c("condition3", "racialresentment", "article_feel_5", "gender", "partyidentification", "ideology", "educ", "income", "age", "fairpt", "vote", "agree1", "agree2", "agree3", "reparations")]

threat_nocult2 <- threat_nocult2[complete.cases(threat_nocult2), ]

threat_nocult2$condition3 = as.factor(threat_nocult2$condition3)
threat_nocult2$gender = as.factor(threat_nocult2$gender)

model_med = lm(article_feel_5 ~ condition3 + gender + racialresentment + partyidentification + ideology + educ + income + age, data = threat_nocult2)

set.seed(2346)
model_out_fairpt = lm(fairpt ~ condition3 * article_feel_5 + gender + racialresentment + partyidentification + ideology + educ + income + age, data=threat_nocult2)
model_combo_fairpt = mediation::mediate(model_med, model_out_fairpt, treat="condition3", mediator="article_feel_5", sims=1000)
summary(model_combo_fairpt)

model_out_vote = lm(vote ~ condition3 * article_feel_5 + gender + racialresentment + partyidentification + ideology + educ + income + age, data=threat_nocult2)
model_combo_vote = mediation::mediate(model_med, model_out_vote, treat="condition3", mediator="article_feel_5", sims=1000)
summary(model_combo_vote)

model_out_agree1 = lm(agree1 ~ condition3 * article_feel_5 + gender + racialresentment + partyidentification + ideology + educ + income + age, data=threat_nocult2)
model_combo_agree1 = mediation::mediate(model_med, model_out_agree1, treat="condition3", mediator="article_feel_5", sims=1000)
summary(model_combo_agree1)

model_out_agree2 = lm(agree2 ~ condition3 * article_feel_5 + gender + racialresentment + partyidentification + ideology + educ + income + age, data=threat_nocult2)
model_combo_agree2 = mediation::mediate(model_med, model_out_agree2, treat="condition3", mediator="article_feel_5", sims=1000)
summary(model_combo_agree2)

model_out_agree3 = lm(agree3 ~ condition3 * article_feel_5 + gender + racialresentment + partyidentification + ideology + educ + income + age, data=threat_nocult2)
model_combo_agree3 = mediation::mediate(model_med, model_out_agree3, treat="condition3", mediator="article_feel_5", sims=1000)
summary(model_combo_agree3)

model_out_rep = lm(reparations ~ condition3 * article_feel_5 + gender + racialresentment + partyidentification + ideology + educ + income + age, data=threat_nocult2)
model_combo_rep = mediation::mediate(model_med, model_out_rep, treat="condition3", mediator="article_feel_5", sims=1000)
summary(model_combo_rep)

# Mediator: Felt threat scale 
threat_nocult2 <- threat_nocult[,c("condition3", "racialresentment", "article_feel_combo_anxiety3", "gender", "partyidentification", "ideology", "educ", "income", "age", "fairpt", "vote", "agree1", "agree2", "agree3", "reparations")]

threat_nocult2 <- threat_nocult2[complete.cases(threat_nocult2), ]

threat_nocult2$condition3 = as.factor(threat_nocult2$condition3)
threat_nocult2$gender = as.factor(threat_nocult2$gender)

model_med = lm(article_feel_combo_anxiety3 ~ condition3 + gender + racialresentment + partyidentification + ideology + educ + income + age, data = threat_nocult2)

set.seed(2346)
model_out_fairpt = lm(fairpt ~ condition3 * article_feel_combo_anxiety3 + gender + racialresentment + partyidentification + ideology + educ + income + age, data=threat_nocult2)
model_combo_fairpt = mediation::mediate(model_med, model_out_fairpt, treat="condition3", mediator="article_feel_combo_anxiety3", sims=1000)
summary(model_combo_fairpt)

model_out_vote = lm(vote ~ condition3 * article_feel_combo_anxiety3 + gender + racialresentment + partyidentification + ideology + educ + income + age, data=threat_nocult2)
model_combo_vote = mediation::mediate(model_med, model_out_vote, treat="condition3", mediator="article_feel_combo_anxiety3", sims=1000)
summary(model_combo_vote)

model_out_agree1 = lm(agree1 ~ condition3 * article_feel_combo_anxiety3 + gender + racialresentment + partyidentification + ideology + educ + income + age, data=threat_nocult2)
model_combo_agree1 = mediation::mediate(model_med, model_out_agree1, treat="condition3", mediator="article_feel_combo_anxiety3", sims=1000)
summary(model_combo_agree1)

model_out_agree2 = lm(agree2 ~ condition3 * article_feel_combo_anxiety3 + gender + racialresentment + partyidentification + ideology + educ + income + age, data=threat_nocult2)
model_combo_agree2 = mediation::mediate(model_med, model_out_agree2, treat="condition3", mediator="article_feel_combo_anxiety3", sims=1000)
summary(model_combo_agree2)

model_out_agree3 = lm(agree3 ~ condition3 * article_feel_combo_anxiety3 + gender + racialresentment + partyidentification + ideology + educ + income + age, data=threat_nocult2)
model_combo_agree3 = mediation::mediate(model_med, model_out_agree3, treat="condition3", mediator="article_feel_combo_anxiety3", sims=1000)
summary(model_combo_agree3)

model_out_rep = lm(reparations ~ condition3 * article_feel_combo_anxiety3 + gender + racialresentment + partyidentification + ideology + educ + income + age, data=threat_nocult2)
model_combo_rep = mediation::mediate(model_med, model_out_rep, treat="condition3", mediator="article_feel_combo_anxiety3", sims=1000)
summary(model_combo_rep)

# Mediator: Pride
threat_nocult2 <- threat_nocult[,c("condition3", "racialresentment", "article_feel_2", "gender", "partyidentification", "ideology", "educ", "income", "age", "fairpt", "vote", "agree1", "agree2", "agree3", "reparations")]

threat_nocult2 <- threat_nocult2[complete.cases(threat_nocult2), ]

threat_nocult2$condition3 = as.factor(threat_nocult2$condition3)
threat_nocult2$gender = as.factor(threat_nocult2$gender)

model_med = lm(article_feel_2 ~ condition3 + gender + racialresentment + partyidentification + ideology + educ + income + age, data = threat_nocult2)

set.seed(2346)
model_out_fairpt = lm(fairpt ~ condition3 * article_feel_2 + gender + racialresentment + partyidentification + ideology + educ + income + age, data=threat_nocult2)
model_combo_fairpt = mediation::mediate(model_med, model_out_fairpt, treat="condition3", mediator="article_feel_2", sims=1000)
summary(model_combo_fairpt)

model_out_vote = lm(vote ~ condition3 * article_feel_2 + gender + racialresentment + partyidentification + ideology + educ + income + age, data=threat_nocult2)
model_combo_vote = mediation::mediate(model_med, model_out_vote, treat="condition3", mediator="article_feel_2", sims=1000)
summary(model_combo_vote)

model_out_agree1 = lm(agree1 ~ condition3 * article_feel_2 + gender + racialresentment + partyidentification + ideology + educ + income + age, data=threat_nocult2)
model_combo_agree1 = mediation::mediate(model_med, model_out_agree1, treat="condition3", mediator="article_feel_2", sims=1000)
summary(model_combo_agree1)

model_out_agree2 = lm(agree2 ~ condition3 * article_feel_2 + gender + racialresentment + partyidentification + ideology + educ + income + age, data=threat_nocult2)
model_combo_agree2 = mediation::mediate(model_med, model_out_agree2, treat="condition3", mediator="article_feel_2", sims=1000)
summary(model_combo_agree2)

model_out_agree3 = lm(agree3 ~ condition3 * article_feel_2 + gender + racialresentment + partyidentification + ideology + educ + income + age, data=threat_nocult2)
model_combo_agree3 = mediation::mediate(model_med, model_out_agree3, treat="condition3", mediator="article_feel_2", sims=1000)
summary(model_combo_agree3)

model_out_rep = lm(reparations ~ condition3 * article_feel_2 + gender + racialresentment + partyidentification + ideology + educ + income + age, data=threat_nocult2)
model_combo_rep = mediation::mediate(model_med, model_out_rep, treat="condition3", mediator="article_feel_2", sims=1000)
summary(model_combo_rep)

# Mediator: Hope
threat_nocult2 <- threat_nocult[,c("condition3", "racialresentment", "article_feel_4", "gender", "partyidentification", "ideology", "educ", "income", "age", "fairpt", "vote", "agree1", "agree2", "agree3", "reparations")]

threat_nocult2 <- threat_nocult2[complete.cases(threat_nocult2), ]

threat_nocult2$condition3 = as.factor(threat_nocult2$condition3)
threat_nocult2$gender = as.factor(threat_nocult2$gender)

model_med = lm(article_feel_4 ~ condition3 + gender + racialresentment + partyidentification + ideology + educ + income + age, data = threat_nocult2)

set.seed(2346)
model_out_fairpt = lm(fairpt ~ condition3 * article_feel_4 + gender + racialresentment + partyidentification + ideology + educ + income + age, data=threat_nocult2)
model_combo_fairpt = mediation::mediate(model_med, model_out_fairpt, treat="condition3", mediator="article_feel_4", sims=1000)
summary(model_combo_fairpt)

model_out_vote = lm(vote ~ condition3 * article_feel_4 + gender + racialresentment + partyidentification + ideology + educ + income + age, data=threat_nocult2)
model_combo_vote = mediation::mediate(model_med, model_out_vote, treat="condition3", mediator="article_feel_4", sims=1000)
summary(model_combo_vote)

model_out_agree1 = lm(agree1 ~ condition3 * article_feel_4 + gender + racialresentment + partyidentification + ideology + educ + income + age, data=threat_nocult2)
model_combo_agree1 = mediation::mediate(model_med, model_out_agree1, treat="condition3", mediator="article_feel_4", sims=1000)
summary(model_combo_agree1)

model_out_agree2 = lm(agree2 ~ condition3 * article_feel_4 + gender + racialresentment + partyidentification + ideology + educ + income + age, data=threat_nocult2)
model_combo_agree2 = mediation::mediate(model_med, model_out_agree2, treat="condition3", mediator="article_feel_4", sims=1000)
summary(model_combo_agree2)

model_out_agree3 = lm(agree3 ~ condition3 * article_feel_4 + gender + racialresentment + partyidentification + ideology + educ + income + age, data=threat_nocult2)
model_combo_agree3 = mediation::mediate(model_med, model_out_agree3, treat="condition3", mediator="article_feel_4", sims=1000)
summary(model_combo_agree3)

model_out_rep = lm(reparations ~ condition3 * article_feel_4 + gender + racialresentment + partyidentification + ideology + educ + income + age, data=threat_nocult2)
model_combo_rep = mediation::mediate(model_med, model_out_rep, treat="condition3", mediator="article_feel_4", sims=1000)
summary(model_combo_rep)

# Mediator: Excitement 
threat_nocult2 <- threat_nocult[,c("condition3", "racialresentment", "article_feel_6", "gender", "partyidentification", "ideology", "educ", "income", "age", "fairpt", "vote", "agree1", "agree2", "agree3", "reparations")]

threat_nocult2 <- threat_nocult2[complete.cases(threat_nocult2), ]

threat_nocult2$condition3 = as.factor(threat_nocult2$condition3)
threat_nocult2$gender = as.factor(threat_nocult2$gender)

model_med = lm(article_feel_6 ~ condition3 + gender + racialresentment + partyidentification + ideology + educ + income + age, data = threat_nocult2)

set.seed(2346)
model_out_fairpt = lm(fairpt ~ condition3 * article_feel_6 + gender + racialresentment + partyidentification + ideology + educ + income + age, data=threat_nocult2)
model_combo_fairpt = mediation::mediate(model_med, model_out_fairpt, treat="condition3", mediator="article_feel_6", sims=1000)
summary(model_combo_fairpt)

model_out_vote = lm(vote ~ condition3 * article_feel_6 + gender + racialresentment + partyidentification + ideology + educ + income + age, data=threat_nocult2)
model_combo_vote = mediation::mediate(model_med, model_out_vote, treat="condition3", mediator="article_feel_6", sims=1000)
summary(model_combo_vote)

model_out_agree1 = lm(agree1 ~ condition3 * article_feel_6 + gender + racialresentment + partyidentification + ideology + educ + income + age, data=threat_nocult2)
model_combo_agree1 = mediation::mediate(model_med, model_out_agree1, treat="condition3", mediator="article_feel_6", sims=1000)
summary(model_combo_agree1)

model_out_agree2 = lm(agree2 ~ condition3 * article_feel_6 + gender + racialresentment + partyidentification + ideology + educ + income + age, data=threat_nocult2)
model_combo_agree2 = mediation::mediate(model_med, model_out_agree2, treat="condition3", mediator="article_feel_6", sims=1000)
summary(model_combo_agree2)

model_out_agree3 = lm(agree3 ~ condition3 * article_feel_6 + gender + racialresentment + partyidentification + ideology + educ + income + age, data=threat_nocult2)
model_combo_agree3 = mediation::mediate(model_med, model_out_agree3, treat="condition3", mediator="article_feel_6", sims=1000)
summary(model_combo_agree3)

model_out_rep = lm(reparations ~ condition3 * article_feel_6 + gender + racialresentment + partyidentification + ideology + educ + income + age, data=threat_nocult2)
model_combo_rep = mediation::mediate(model_med, model_out_rep, treat="condition3", mediator="article_feel_6", sims=1000)
summary(model_combo_rep)

